Changes between Initial Version and Version 1 of Ticket #35665, comment 3


Ignore:
Timestamp:
Aug 11, 2024, 10:15:55 PM (6 weeks ago)
Author:
Andrew

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35665, comment 3

    initial v1  
    33Yes, it returns them in database order, which is acceptable in this case.
    44
    5 This **actually** came up due to a Model having no {{{Meta.ordering}}}, which is our standard.  All ordering must be explicit at the query level.
     5The actual issue was a Model having no {{{Meta.ordering}}}.  Since both cause the issue, and we  require `order_by()` to be explicit at the query level, I used the `.order_by()`  example.  The following will also fail, as the products model has no default ordering:
     6
     7{{{
     8short_list = Prefetch(
     9    "products",
     10    queryset=Product.objects.all()[:10],
     11    to_attr="short_list",
     12)
     13class Product(models.Model):
     14    class Meta:
     15        # ordering = ['name']       
     16        verbose_name_plural = "Products"
     17}}}
Back to Top