This function is used in a view in which I list the search results. In my search form, I have some ModelChoiceFields for searching by foreign keys. A normal workflow means that our current search is becoming more accurate, so in order to disable a lot of inappropriate results, I try to delete records that do not return a result if no other search parameters are changed.
I use a set of query objects to limit the suggestions in some drop-down lists. I use the abstract dropdown lists to filter by foreign key the list of my objects.
My function argument for filtering is the set of object requests at the moment:
class MySearchForm(Form):
things = ModelChoiceField(queryset=models.Thing.objects.none())
def __init__(self, *args, **kwargs):
my_objects_queryset = kwargs.pop('my_objects_queryset',models.Thing.objects.all())
super(MySearchForm, self).__init__(*args, **kwargs)
self.fields['things'].queryset = \
models.Thing.objects.filter(object__in=my_objects_queryset).distinct()
My problem is how to remove 'where close' from an existing query_set. Here I want to remove from my_objects_queryset where it closes the filter withthing = ForeignKey(models.Thing)
Is it possible?
Something like a way to list all the filters of our request and edit / delete them on the fly.
source
share