Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 13, 2010 09:51:22

n.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Display related field in queryset


Hello,

I'm usinghttp://code.google.com/p/django-jqgrid/to display grids
into a Django application. Since I'm pretty new to Django I don't know
how to tell Django to retrurn the value of the related field instead
of the id of the related field. What I do now is: travels =
Travel.objects.values('date','destination'), but that returns the date
of the travel and the id of the destination, FK to Destination model/
table. How should I query Django so it returns the description of the
destination instead of its id?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 13, 2010 11:36:01

Marcos M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Display related field in queryset


You can use field lookups:http://docs.djangoproject.com/en/dev/topics/db/queries/#field-lookups-introie: Travels.objects.values('date', 'destination__name')

Rgds,
Marcos

On Mon, Dec 13, 2010 at 6:51 AM, nsbk <pedro...@gmail.com> wrote:

> Hello,
>
> I'm usinghttp://code.google.com/p/django-jqgrid/to display grids
> into a Django application. Since I'm pretty new to Django I don't know
> how to tell Django to retrurn the value of the related field instead
> of the id of the related field. What I do now is: travels =
> Travel.objects.values('date','destination'), but that returns the date
> of the travel and the id of the destination, FK to Destination model/
> table. How should I query Django so it returns the description of the
> destination instead of its id?
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>


--
Some people, when confronted with a problem, think “I know, I'll use regular
expressions.” Now they have two problems.

Jamie Zawinski, in comp.emacs.xemacs

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 19th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support