Try this:
ExampleModel.objects.all().order_by('updated_at' , '-created_at')
Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos




El vie, 21 ene 2022 a las 1:54, Aadil Rashid (<aadil10121...@gmail.com>)
escribió:

> class ExampleModel(models.Model):
> is_active = models.BooleanField(default=True)
> created_at = models.DateTimeField(auto_now_add=True)
> updated_at = models.DateTimeField(auto_now=True)
>
>
>
> I want to query on UserModel such that the Query set which I get should be
> orderable in terms of time difference of updated_at - created_at,
> I tried
> ExampleModel.objects.all().order_by('updated_at' - 'created_at')
> but this is not working
> it throws, *TypeError*: unsupported operand type(s) for -: 'str' and 'str'
>
>
> Django Family Please Help...................
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAAYXZx8sABKuJn5Q1ATeHnYsrixfU9wTH_TtPYoR5%3DeAd8DOzA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAYXZx8sABKuJn5Q1ATeHnYsrixfU9wTH_TtPYoR5%3DeAd8DOzA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKVvSDDy%2BnJNcFE-xpz38zfDVYgw6P3zDZ9BJ_5-EsoAtDDLTw%40mail.gmail.com.

Reply via email to