Skip to main content

Questions tagged [django-filter]

For questions concerning the use of the 3rd-party library django-filter. Do not use this tag for questions asking about simply filtering querysets.

0 votes
0 answers
16 views

Django - Filtering on annotated count field returns unexpected values

I have a function that filters a Django queryset on the number of linked objects. Used inside a graphene-django project, it allows me to dynamically create filter fields for a bunch of objects without ...
Chris Hacker's user avatar
0 votes
1 answer
27 views

django-filter DateFromToRangeFilter can't not filte between two dates

I'm building vue3 + django DRF project. I'm making my consumelists from and I want to filte bewteen two days. likes 2024-06-01 to 2024-06-30. I used DateFromToRangeFilter but not work. please help. ...
New's user avatar
  • 1
1 vote
0 answers
33 views

Django REST ModelViewSet view returns 404 after PATCH

I have ModelViewSet view in django rest framework project. I am trying to filter documents that are not live, I mean are not on main view. To filter I am using params: http://localhost:8000/documents?...
user25455142's user avatar
3 votes
1 answer
45 views

How to Filter by Status in Django Rest Framework with Square Brackets in Query Params

I'm encountering an issue with filtering a model by status in Django Rest Framework. Here's my current setup: When I filter using status=1,14, it works perfectly: class DepartmentFilter(filters....
aserra's user avatar
  • 133
2 votes
1 answer
39 views

Django Rest Framework custom filter with default search and ordering filter

I have a project in Django Rest Framework where I need have endpoint where I'm able to search Document objects by title and text and possibility to search object is active and inactive, using to this ...
user25455142's user avatar
0 votes
0 answers
15 views

SimpleListFilter and M2M fields as JSON

My setup contains Product information that come from a JSON field and are linked to a Page in a m2m relation (Page like in a catalogue). class Page(models.Model): ... products = models....
xtlc's user avatar
  • 1,316
0 votes
0 answers
98 views

Django: How to filter based on custom field generated in serializer to_representation

I have a custom field in my extra action view that gets added by overriding to_representation() in serializer. I want to add a filter based on that value. How can I achieve that? views.py class ...
TechSavy's user avatar
  • 1,332
0 votes
0 answers
11 views

Referencing a foreign key field attached to another model in a Django filter

I have a Profile model which is related to the Django User model via a 1:1 relationship. In the profile model is a field "nickname." I am filtering a table with a foreign key to the User ...
JJ Ryan's user avatar
  • 57
0 votes
0 answers
45 views

Django puts AND clause to lookup "in"

Django 4.2 together with graphene-django filters is making my query return empty results class ExampleFilterSet(FilterSet): label__name__in = StringInFilter(method="filter_labels") ...
Jolly's user avatar
  • 184
0 votes
0 answers
28 views

How to filter foreign key for using ModelMultipleChoiceFilter in DRF?

I'm getting trouble with using ModelMultipleChoiceFilter in DRF. First, I have three models. # JUST STRUCTURE class A -> fields : [user:User] class B -> fields : [a:A(related_name="b"),...
chocho's user avatar
  • 91
1 vote
2 answers
43 views

Problem with getting model instances in specific order

I have a list of passport data of users. I need to get users queryset in the same sequence as their passport data ordered in the list. Here is the list with passport data: lst = ['AA1111111', '...
HollowPillow's user avatar
1 vote
1 answer
166 views

Conditional filling of autocomplete dropdown in Django backend with admin_auto_filters

My models.py: from smart_selects.db_fields import ChainedForeignKey class Funder(models.Model): name = models.CharField(max_length=200) scheme = models.ManyToManyField('Scheme', blank=True, ...
HBMCS's user avatar
  • 735
1 vote
1 answer
19 views

Django-filter Multiple Foreign Keys from one model

I have model with 2 fields place_of_loading and place_of_unloading with foreign key to the same model ConstructionSite. class DailyPerformance(models.Model): date = models.DateField() driver = ...
Teofilex's user avatar
0 votes
1 answer
79 views

I'm Fetching Error between django and django-filter

My problem is that the django-filter library does not work correctly with the choice fields in django rest framework: models.py class Incident(models.Model): caller = models.ForeignKey( '...
Nik Vozakssar's user avatar
0 votes
2 answers
52 views

Django 'When' object is not iterable

I'm using django-filter to show work-hour of employs. models.py: ... class Attendance(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="...
Little Elite's user avatar

15 30 50 per page
1
2 3 4 5
92