Karen Tracey-2 wrote:
> 
> On Tue, Nov 17, 2009 at 6:43 AM, Radhikavk <radhi3...@gmail.com> wrote:
> 
>>
>> I tried this i dis not get solution
>>
>> i m getting a list from rooms table
>>
>> room_list=rooms.objects.all()
>>
>> This will give me the room type id when i print room_list.room_type_id
>> but
>> for this id i need a name which is in room_types table
>>
> 
> room_list as you have assigned it above won't have a room_type_id so I'm
> confused by what you are saying you can do -- what you say you can do
> would
> produce an error.
> 
> room_list is a QuerySet, you first need to pull an individual instance of
> a
> rooms model out of the set before you can access any of its attributes
> such
> as room_type.  Once you have a rooms instance, it will have a rooms_type
> instance in its room_type attribute.  From the rooms_type instance you can
> access any of its attributes using standard Python dot notation.  For eg:
> 
> for room in room_list:
>     print 'Room type is: %s' % room.room_type.room_type_name
> 
> If you have not worked through the tutorial I encourage you to do so:
> 
> http://docs.djangoproject.com/en/dev/intro/tutorial01/
> 
> Also you might find this section of the documentation helpful:
> 
> http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects
> 
> Karen
> 
> --
> 
> 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 at
> http://groups.google.com/group/django-users?hl=.
> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-use-subqueries-in-django-tp26387486p26390136.html
Sent from the django-users mailing list archive at Nabble.com.

--

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 at 
http://groups.google.com/group/django-users?hl=.


Reply via email to