Merge pull request #1629 from alexgleason/snippets-doc-fix

Snippets docs: __str__ instead of __unicode__
This commit is contained in:
Karl Hobley 2015-08-27 11:44:25 +01:00
commit ebf212d850

View file

@ -32,12 +32,12 @@ Here's an example snippet from the Wagtail demo website:
FieldPanel('text'),
]
def __unicode__(self):
def __str__(self): # __unicode__ on Python 2
return self.text
The ``Advert`` model uses the basic Django model class and defines two properties: text and URL. The editing interface is very close to that provided for ``Page``-derived models, with fields assigned in the panels property. Snippets do not use multiple tabs of fields, nor do they provide the "save as draft" or "submit for moderation" features.
``@register_snippet`` tells Wagtail to treat the model as a snippet. The ``panels`` list defines the fields to show on the snippet editing page. It's also important to provide a string representation of the class through ``def __unicode__(self):`` so that the snippet objects make sense when listed in the Wagtail admin.
``@register_snippet`` tells Wagtail to treat the model as a snippet. The ``panels`` list defines the fields to show on the snippet editing page. It's also important to provide a string representation of the class through ``def __str__(self):`` so that the snippet objects make sense when listed in the Wagtail admin.
Including Snippets in Template Tags
-----------------------------------
@ -145,7 +145,7 @@ To attach multiple adverts to a page, the ``SnippetChooserPanel`` can be placed
SnippetChooserPanel('advert', Advert),
]
def __unicode__(self):
def __str__(self): # __unicode__ on Python 2
return self.page.title + " -> " + self.advert.text