We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If I create an admin model :
class MyModelAdmin(AdminAdvancedFiltersMixin, admin.ModelAdmin): advanced_filter_fields = ['related_obj'] # related_obj is a foreign key
And try to create a custom filter with related_obj + EQUALS + 1 I get the following traceback when executing the filter:
related_obj
EQUALS
1
Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 149. response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 147. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper 541. return self.admin_site.admin_view(view)(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner 244. return view(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/advanced_filters/admin.py" in changelist_view 113. ).changelist_view(request, extra_context=extra_context) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper 67. return bound_func(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func 63. return func.__get__(self, type(self))(*args2, **kwargs2) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in changelist_view 1470. self.list_max_show_all, self.list_editable, self) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/main.py" in __init__ 78. self.queryset = self.get_queryset(request) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/main.py" in get_queryset 326. new_qs = filter_spec.queryset(request, qs) File "/usr/local/lib/python2.7/dist-packages/advanced_filters/admin.py" in queryset 53. return queryset.filter(query).distinct() File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in filter 790. return self._filter_or_exclude(False, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _filter_or_exclude 808. clone.query.add_q(Q(*args, **kwargs)) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in add_q 1243. clause, _ = self._add_q(q_object, self.used_aliases) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in _add_q 1263. current_negated, allow_joins, split_subq) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in _add_q 1269. allow_joins=allow_joins, split_subq=split_subq, File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in build_filter 1194. lookup_class = field.get_lookup(lookups[0]) File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py" in get_lookup 693. raise TypeError('Related Field got invalid lookup: %s' % lookup_name) Exception Type: TypeError at /admin/api/mymodel/ Exception Value: Related Field got invalid lookup: iexact
Am I doing something wrong ?
The text was updated successfully, but these errors were encountered:
Ops, sorry I found out that I need to do it like this :
advanced_filter_fields = ['related_obj__id']
It would be nice though it it could work with related_obj and related_obj_id
related_obj_id
Sorry, something went wrong.
My pull request fixes this problem #74
You can wait for the update of the main branch or update you module from my branch pip install git+https://github.com/ivansurov/django-advanced-filters.git@feature
No branches or pull requests
If I create an admin model :
And try to create a custom filter with
related_obj
+EQUALS
+1
I get the following traceback when executing the filter:Am I doing something wrong ?
The text was updated successfully, but these errors were encountered: