Sunday, December 21, 2014

Re: Select a single field from database (postgresql)

Or use .latest()

On 19/12/2014 11:00 pm, "aRkadeFR" <contact@arkade.info> wrote:
Hello Cássio,

You first need to map your cars table with a Model in Django
(https://docs.djangoproject.com/en/1.7/topics/db/models/),
then you can construct your query something like this:

Car.objects.order_by('-registered').last()

Check out the documentation on queries here:
https://docs.djangoproject.com/en/1.7/topics/db/queries/

Have a good one,

aRkadeFR


On 12/19/2014 12:51 PM, Cássio Van Helden Gameiro wrote:
Hi, i have a database with many cars, and i want to select the last car based the hour that it was registered, can someone help me?

Thanks.
--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fecb3393-d336-4aa8-8058-f6bbf9cfbfc4%40googlegroups.com.
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/54941319.9040806%40arkade.info.
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHqTbjnoEONUmejPA9f9KodPhb2pzyZzCWkcrYVoNfza1gyFJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment