Hi Djangoers!
I'm making a database system which holds information about doctors and
what universities they got their degree from. It consists of two
models, Doctor and Origin.
In Doctor, I make a field, origin, which is a ForeignKey to Origin,
surprisingly :-)
The Origin model has a name of the university, and the country where
this university is located.
The Origin's __unicode__ class returns the name of the university,
since this is what I need for the most part, but in the list of
doctors, I would very much like to be able to filter by the COUNTRY of
origin, not the university, since at deployment, there will probably
be a lot of universities from the same country.
# This is what I have (admin.py)
class DoctorAdmin(admin.ModelAdmin):
list_filter = ['origin']
# This is what I want: (admin.py)
class DoctorAdmin(admin.ModelAdmin):
list_filter = ['origin.country']
.. or something like that.
I have tried multiple things, but I always end up realizing that the
field I need to filter by needs to be represented in the Doctor-model.
Any suggestions to what I might do to fix this?
Thanks in advance,
Kspr
PS: Some extra code if needed: (model.py)
class Origin(models.Model):
name = models.CharField(max_length=200)
country = models.CharField(max_length=2, choices=COUNTRIES)
class Doctor(models.Model):
name = models.CharField(max_length=200)
hire_date = models.DateField('date hired')
origin = models.ForeignKey(Origin)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---