Thanks!!!

On Feb 26, 10:28 am, Eric Abrahamsen <gir...@gmail.com> wrote:
> On Feb 26, 2009, at 6:23 PM, marco sedda wrote:
>
>
>
> > Hi,
> >   I want to select a "single" field from a table, i've read the
> > QuerySet API reference but i can't find anything to solve my query.
>
> > Just to explain:
>
> > If i've a table like:
>
> > User
> >   first_name = models.CharField(max_length=30)
> >   last_name = models.CharField(max_length=30)
>
> > how i can execute a sql query "SELECT first_name FROM User" with
> > QuerySet API?
>
> You want the values() queryset call 
> (http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields
> ). Your query would probably look like  
> User.objects.values('first_name'), or if you wanted a plain list  
> (values usually returns a dictionary), you can use values_list() with  
> the 'flat' parameter.
>
> Hope that helps,
> Eric
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to