Suppose that you have a Section model that has a foreign key to
Magazine, and the field in the Section model is called magazine. You
can then do something like this once you get the section:

s = Section.objects.select_related.get(....)
s.magazine.id will return the id of the magazine, if it has a name then
s.magazine.name will return the name.

This will do the all the related querries in one shot. You can also do:

s = Section.objects.get(....)
s.magazine.id will still return the mangazine id, but it will also
query the database twice. Once to get the Section object, then second
time to get the details fo the magazine object.

Assuming that you want to put this into a form, you'll probably have to
do something like:

new_data['magazine'] = s.magazine.id

in the forms page.

Hope that this helps.


--~--~---------~--~----~------------~-------~--~----~
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to