Have you tried using the IN filter?

Student.objects.filter(school__in = [A, B])


http://www.djangoproject.com/documentation/db-api/#in


-Bill


On Feb 3, 2008, at 1:41 PM, [EMAIL PROTECTED] wrote:


Hi,

I have a situation whereby I need to use filters with "OR" .

Here is a description of my model:

1) A student affiliated to only one school. (ForeignKey)
2) A student can only have one publication. (ForeignKey)
3) A student can have multiple research interest(s). (ManytoManyField)

I want to use the filter (which is awesome!!). However, I want to
filter
all students belonging to school A OR school B (with other filter
criteria,
on other columns (all ANDed).

Can I do that with the django Admin? If so, how?

Below is the actual model of my classes:

I appreciate any help.

Thanks,
sanrio



class School (models.Model):
   name = models.CharField (maxlength=60)
   def __str__ (self):
       return self.name
   class Admin:
       list_display = ('name',)
   class Meta:
       db_table = 'School'

Publication (models.Model):
   name = models.CharField (maxlength=50)
   def __str__ (self):
       return self.name
   class Admin:
       list_display = ('name',)
   class Meta:
       db_table = 'Publication'

class Student (models.Model):
   first_name = models.CharField (maxlength=30)
   last_name = models.CharField (maxlength=30)
   email = models.EmailField ()
   phone = models.PhoneNumberField ()
   research = models.ManyToManyField (Research, null=True,
blank=True)
   publication = models.ForeignKey (Publication)
   affiliation = models.ForeignKey (School)

class Admin:
       list_display = ('last_name', 'first_name', 'affiliatiation')
       list_filter = ('affiliation', 'publication', 'research')






--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---







Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to