Skip to content

Commit

Permalink
Merge pull request #30 from Jerome-Celle/allow_related_field
Browse files Browse the repository at this point in the history
Allow related field to be used in filter
  • Loading branch information
farhan0581 authored Apr 18, 2020
2 parents 584cab5 + dde5a46 commit 6cac9ce
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion admin_auto_filters/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AutocompleteFilter(admin.SimpleListFilter):
is_placeholder_title = False
widget_attrs = {}
rel_model = None
parameter_name = None
form_field = forms.ModelChoiceField

class Media:
Expand All @@ -37,7 +38,9 @@ class Media:
}

def __init__(self, request, params, model, model_admin):
self.parameter_name = '{}__{}__exact'.format(self.field_name, self.field_pk)
if self.parameter_name is None:
self.parameter_name = '{}__{}__exact'.format(self.field_name,
self.field_pk)
super().__init__(request, params, model, model_admin)

if self.rel_model:
Expand Down

0 comments on commit 6cac9ce

Please sign in to comment.