No request passed to custom filter as self.request
See original GitHub issueHi,
I could be doing something wrong or else this is a bug.
When creating a custom filter and I override the queryset as per the Filtering docs:
@property
def qs(self):
# The query context can be found in self.request.
print(self.request.user)
return super(CustomFilter, self)
self.request is always None
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
django-filter custom filter not get queryset - Stack Overflow
To fix this, you need to pass the user_id (of the worker you wish to check) to this queryset somehow. Maybe using the...
Read more >No field filters form on the browsable API #64 - GitHub
I have a rest_framework_filters.FilterSet-derived class which works perfectly for filtering but it doesn't show any field filters in the ...
Read more >Filtering - Django REST framework
Overriding this method allows you to customize the queryset returned by the view ... user = self.request.user return Purchase.objects.filter(purchaser=user) ...
Read more >ModelAdmin List Filters - Django documentation
For custom filtering, you can define your own list filter by subclassing ... 'decade' def lookups(self, request, model_admin): """ Returns a list of...
Read more >Django Admin list_filter | Blog - DoTheDev
Fields that exist in the database; Default Date Filter; Custom Filter ... def queryset(self, request, queryset): if not self.value(): return ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @syrusakbary any chance this could be released? It feels like a pretty major blocker (certainly is for our use case of filtering a list for a logged in user), and installing from master breaks a lot of Python packaging workflows, not to mention means that other unreleased and possibly untested code might be used in production.
In my case, I was using
DjangoFilterConnectionField
, and I could see that it’sconnection_resolver
method wasn’t supplying therequest
parameter. If you look at the master branch, you can see that therequest
object was just added as a parameter in 1db1cbdd9. I don’t know why, but the latest version in PyPI is 2.0.0, which doesn’t include that commit. It seems as though we’re due for a release, but I can’t find any tickets saying when.