python - How do I get value from another filter in a django filter set -


i have custom django filter , want value of "distance" inside filter_location function, ideas how achieve this?

reason wanting so, doing external api call data , need both values @ same time.

class listingfilter(django_filters.filterset):      def filter_location(self, queryset, value):         # want 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 

everything in self.data ordered dict:

class listingfilter(django_filters.filterset):     def filter_location(self, queryset, value):         print(self.data['distance'])         return queryset 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -