I am trying to create use the filter method with django-filters
See an example of the models below:
class Chicken(TimeStampedModel):
eggs = ForeignKey(Egg)
class Egg(TimeStampedModel):
hatched = BooleanField(default=False)
See an example of my current set up for the filter:
class ChickenFilter(FilterSet):
eggs__contains = ModelChoiceFilter(name="eggs", method='hatched_eggs', queryset=Eggs.objects.all())
def hatched_eggs(self, queryset, name, value):
print "We got eggs"
return queryset.filter(eggs__hatched=True)
The problem is that the method doesnt even print We got eggs when I hit the url. It just returns an empty queryset.
eggs__containsisn't in the querystring, the filter won't execute.