On Mon, Jul 27, 2009 at 6:01 PM, irishsteve <steve...@gmail.com> wrote:
> > Hi > > I'm new to Django, so thanks in advance for taking the time to help > me! I can't work out how to reference a foreignKey in the list_filter > method. > > Here are the two relevant objects from my model: > > [snip] Everything is working correctly however, in the list_filter method, > I've been trying to do: > > list_filter = ('competition.startDate', 'division') > > but it's just throwing an error. I've done quite a lot of digging > about and I'm sure the answer is staring me in the face, but I haven't > been able to work it out. > You are trying to filter on a field in the related model? I do not get the impression from the documentation for list_filter ( http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter) that that is supported. It states: "(list_filter) should be a list of field names, and each specified field should be either a BooleanField, CharField, DateField, DateTimeField, IntegerField or ForeignKey." So, specifying the ForeignKey "competition" should work, but I'm not sure there is any support for trying to follow that ForeignKey and filter on the value of a field in the related model. Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---