Default lookup expressions #1721
-
|
This is a very minor complaint, but I am curious to know if there is an easy fix. ExampleI have been using a FilterSet with the fields defined in a list. class UserFilter(django_filters.FilterSet):
class Meta:
model = User
fields = ['username', 'last_login']I have been sending requests to this endpoint as shown below. The FilterSet seemingly interprets these as response = requests.get(url, params={'username': 'ella'})I then realise that I want to add support for class UserFilter(django_filters.FilterSet):
class Meta:
model = User
fields = {
'username': ['exact', 'in'],
'last_login': ['exact', 'in'],
}Now I must append response = requests.get(url, params={'username': 'ella'}) # no longer works
response = requests.get(url, params={'username__exact': 'ella'})
response = requests.get(url, params={'username__in': 'ella, greg'})ProblemIt seems unfortunate that adding support for |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hey @isaac-blanc — Erm... what you describe as desired is the actual behaviour — or it should be. From the test suite: The form there has the So something else must be going on in your case. |
Beta Was this translation helpful? Give feedback.
Hey @isaac-blanc — Erm... what you describe as desired is the actual behaviour — or it should be.
From the test suite:
The form there has the
pricefield you're looking for.So somethin…