views:

11

answers:

0

Hello,

We are having problems getting the filtering in the admin interface working the way we would like it to.

We have the following:

models.py:

class Person(models.Model):
  first_name = models.CharField(blank=True)
  last_name = models.CharField(blank=True)

class Affiliation(models.Model):
  person = models.ForeignKey(Person)
  affiliation = models.CharField(choices=AFFILIATION_CHOICES)
  title = models.CharField(blank=True)

admin.py:

class AffiliationInline(admin.TabularInline):
  model = Affiliation

class PersonAdmin(admin.ModelAdmin):
  inlines = [ AffiliationInline, ]

admin.site.register(Person, PersonAdmin)

Each person can have multiple affiliations. On the admin screen for a Person, we want to be able to filter based on the affiliation field. Unfortunately, this does not appear to be possible with our current configuration. We would use a ManyToManyField to an Affiliation in the Person model, except for the fact that every Affiliation will have a different title.

Does anyone know of a way of doing this?

Bob Guidinger