mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-20 23:00:58 +00:00
Document ineffectiveness of specifying Page._meta.ordering
This commit is contained in:
parent
fd821179cd
commit
db14a1dcf4
1 changed files with 21 additions and 0 deletions
|
|
@ -77,3 +77,24 @@ Make your model names more friendly to users of Wagtail using Django's internal
|
|||
verbose_name = "Homepage"
|
||||
|
||||
When users are given a choice of pages to create, the list of page types is generated by splitting your model names on each of their capital letters. Thus a ``HomePage`` model would be named "Home Page" which is a little clumsy. ``verbose_name`` as in the example above, would change this to read "Homepage" which is slightly more conventional.
|
||||
|
||||
|
||||
Page QuerySet ordering
|
||||
----------------------
|
||||
|
||||
``Page``-derived models *cannot* be given a default ordering by using the standard Django approach of adding an ``ordering`` attribute to the internal ``Meta`` class.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class NewsItemPage(Page):
|
||||
publication_date = models.DateField()
|
||||
...
|
||||
|
||||
class Meta:
|
||||
ordering = ('-publication_date', ) # will not work
|
||||
|
||||
This is because ``Page`` enforces ordering QuerySets by path. Instead you must apply the ordering explicitly when you construct a QuerySet:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
news_items = NewsItemPage.objects.live().order_by('-publication_date')
|
||||
|
|
|
|||
Loading…
Reference in a new issue