Tuesday, January 8, 2019

Re: queries and date ordering

No you can't rely on it being the same order, if the database is re-indexed or reorged that order might change.

On Tue, Jan 8, 2019 at 9:18 PM Mike Dewhirst <miked@dewhirst.com.au> wrote:
If I have a model with ...

     created = models.DateTimeField(auto_now_add=True)

... and in class Meta
         ordering = ['-created']

Is it true that with multiple records where the query search params are
identical the first record returned by the query will always be the most
recent?

Postgres

Thanks

Mike

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6e8deada-5376-7865-8531-6aaf59c6d0e6%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHtg44A%3DDULMew1w%2BCCjRFepY5TD9bYWTSWzhRtnRxWy-Vn71Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment