I have the following models in my models.py file:

>> class Person(models.Model):
>>   pid = models.AutoField(primary_key=True)
>>   fname = models.CharField(max_length=50)
>>   lname = models.CharField(max_length=50)

>> class Books(models.Model)
>>   bid = models.AutoField(primary_key=True)
>>   name = models.CharField(max_length=50)
>>   pid = models.ForiegnKey()

In my views.py, I'd like to run a query that returns a list of people
and their books, where "st" are the "search terms" being passed into
the view:

>> results = Person.objects.filter(Q(fname__istartswith=st) | 
>> Q(lname__istartswith=st))

This only returns the "Person" object.  Is there a "Django-y" way to
have it return both associated objects?  From what I can tell, it
looks like I need to use "Person.objects.extra()" to tie in the
additional "where" statements.

I apologize in advance if I've missed something obvious.  New to
Django and just looking for help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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