I have since discovered that I can use the following: 585 if len(name) > 0: 586 members = MemberRole.objects.filter( Q(member__first_name = 'John') | Q(member__last_name = 'John'), 587 start_date__lte = today, 588 end_date__gte = today, 589 )
Except I am still curious about the .extra() issue I was having before as it will allow me to use regular expressions (which were not introduced as __regex until 1.0) On Jun 25, 10:47 am, Realpolitik <cav...@gmail.com> wrote: > Hello, I'm using Django 0.96 and it is not possible to upgrade to > 1.1/2 yet. I am attempting to perform the following function: "Get all > of the MemberRole objects filtered by start date and end date, and > also filtered by the Member's (foreign key relationship) first name OR > last name. > > MemberRole: start_date, end_date, member (foreign key) > Member: first_name, last_name > > 585 if len(name) > 0: > 586 members = MemberRole.objects.select_related > ('member').filter( > 587 start_date__lte = today, > 588 end_date__gte = today, > 589 ).extra( > 590 where=['(congress_member.first_name = %s OR > congress_member.last_name =%s)'], > 591 params=[name, name], > 592 #tables=[Member._meta.db_table], > 593 ) > > The error I get is: > > Exception Value: missing FROM-clause entry for table > "congress_member" LINE 1: ...bers", "congress_roles", > "congress_states" WHERE (congress_m... ^ > > I get the same error whether I use congress_member or member in the > where statement. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---