it would probably be better to use a custom "Func"[1] and a custom "Query
Expression" [2] than user QuerySet.extra

[1] https://docs.djangoproject.com/en/1.9/ref/models/database-functions
[2] https://docs.djangoproject.com/en/1.9/ref/models/expressions/



On Mon, May 23, 2016 at 11:16 AM, Ketan Bhatt <[email protected]> wrote:

> 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.
>



-- 
Fábio C. Barrionuevo da Luz
Palmas - Tocantins - Brasil - América do Sul

http://pythonclub.com.br/

Blog colaborativo sobre Python e tecnologias Relacionadas, mantido
totalmente no https://github.com/pythonclub/pythonclub.github.io .

Todos são livres para publicar. É só fazer fork, escrever sua postagem e
mandar o pull-request. Leia mais sobre como publicar em README.md e
contributing.md.
Regra básica de postagem:
"Você" acha interessante? É útil para "você"? Pode ser utilizado com Python
ou é útil para quem usa Python? Está esperando o que? Publica logo, que
estou louco para ler...

-- 
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/CAPVjvMZ3UOnmK-ynRuuTZFZUO4hLp91ZPkthj%2BNLQT%3D5jtcvhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to