Take a look at the `extra` method of the queryset in Django. It allows you to 
do what you are trying to do by raw SQL. 

https://docs.djangoproject.com/en/1.9/ref/models/querysets/#django.db.models.query.QuerySet.extra

Check the above link, the example with `annotate` will be interesting for you. 

I think your aim should be to create a new field and then do a `order_by` and 
`first`. 

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/5b556c8b-2012-4bd7-89c5-bddbbdb4c3b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to