queries and date ordering

14 views
Skip to first unread message

Mike Dewhirst

unread,
Jan 9, 2019, 12:18:39 AM1/9/19
to Django users
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

Dylan Reinhold

unread,
Jan 9, 2019, 12:30:28 AM1/9/19
to django...@googlegroups.com
No you can't rely on it being the same order, if the database is re-indexed or reorged that order might change.

--
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...@googlegroups.com.
To post to this group, send email to django...@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.

Mike Dewhirst

unread,
Jan 9, 2019, 1:01:14 AM1/9/19
to django...@googlegroups.com
On 9/01/2019 4:29 pm, Dylan Reinhold wrote:
> No you can't rely on it being the same order, if the database is
> re-indexed or reorged that order might change.

Thanks

>
> On Tue, Jan 8, 2019 at 9:18 PM Mike Dewhirst <mi...@dewhirst.com.au
> <mailto:mi...@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...@googlegroups.com
> <mailto:django-users%2Bunsu...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> --
> 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...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@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
> <https://groups.google.com/d/msgid/django-users/CAHtg44A%3DDULMew1w%2BCCjRFepY5TD9bYWTSWzhRtnRxWy-Vn71Q%40mail.gmail.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages