-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AllLookupsFilter does not work w/ FilterSet mixins #82
Comments
Hi @NotSqrt
No, django-filter is a very similar abstraction to standard django forms and is in fact built on top of them. There are no abstract Could you provide a more complete stack trace? That's not enough information to go off of. |
Here is a longer trace:
when my code looks like: class MessageMixin(FilterSet):
common_field = AllLookupsFilter('field_name')
# no model in Meta class, this is a mixin
class ActualFilter1(MessageMixin, FilterSet):
# other filters
class Meta:
model = MyModel1
class ActualFilter2(MessageMixin, FilterSet):
# other filters
class Meta:
model = MyModel2 The exception is raised at import time, so If I simply do: class MessageMixin(object):
common_field = AllLookupsFilter('field_name')
class ActualFilter1(MessageMixin, FilterSet):
# other filters
class Meta:
model = MyModel1
class ActualFilter2(MessageMixin, FilterSet):
# other filters
class Meta:
model = MyModel2 the Whereas for modelforms, it works perfectly to do: class FormMixin(ModelForm):
common_field = AllLookupsFilter('field_name')
# no model in Meta
class ActualForm1(FormMixin):
# other filters
class Meta:
model = MyModel1
class ActualForm2(FormMixin):
# other filters
class Meta:
model = MyModel2 |
In django's |
Ah, that makes more sense. Checking for the presence of the model is the right thing to do here. |
Fix #82, make all lookups work w/ FilterSet mixins
Alright, this should be fixed on master - it was a straightforward change. |
Great ! Thanks ! |
Hi !
cf https://docs.djangoproject.com/en/1.9/topics/db/models/#abstract-base-classes
Is there an equivalent for FilterSets ?
When I do:
I get an error :
If I do
class FilterMixin(object): ..
, the common filters are not detected.I would really like not having to repeat the fields multiple times !
Thanks !
The text was updated successfully, but these errors were encountered: