Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
How do I get value from another filter in a django filter set

I have a custom django filter and I want to get the value of "distance" inside the filter_location function, any ideas how I achieve this?

Reason for wanting to do so, I am doing an external API call to get data and need both the values at the same time.

class ListingFilter(django_filters.FilterSet):

    def filter_location(self, queryset, value):
        # Want to get the distance filter value here
        if value:
            #Location value


    def filter_distance(self, queryset, value):
        pass

    distance = django_filters.CharFilter(label='Distance', method=filter_distance)
    location = django_filters.CharFilter(label='Location', method=filter_location)

    class Meta:
        model = Company
        fields = ['distance', 'service', 'tags', 'location']


class CompanyListView(viewsets.ReadOnlyModelViewSet):
    queryset = Company.objects.all()
    filter_class = ListingFilter
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

everything is in self.data as an ordered dict:

class ListingFilter(django_filters.FilterSet):
    def filter_location(self, queryset, value):
        print(self.data['distance'])
        return queryset
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!