Hello, I am currently trying to implement the filter-functionality into my SHOP project, I have a product model that has a many2many relation to a catchphrase model. My filter looks like this: (same as docs)
class FilterForm(NgModelFormMixin, Bootstrap3Form):
scope_prefix = 'filters'
class CatchphraseFilter(FilterSet):
catchphrases = ModelMultipleChoiceFilter(
queryset=Catchphrase.objects.all(),
widget=SelectMultiple(attrs={'ng-change': 'filterChanged()'})
)
class Meta:
model = Product
form = FilterForm
fields = ['catchphrases']
@classmethod
def get_render_context(cls, request, `queryset):`
filter_set = cls(data=request.GET)
filter_field = filter_set.filters['catchphrase'].field
filter_field.queryset = filter_field.queryset.filter(
id__in=queryset.values_list('catchphrases'))
return dict(filter_set=filter_set)
the widget works fine, only the catchphrases that are currently used by products get displayed, but when I click on one of them the site reloads and nothing happens. (Also when I use "/?catchphrases", the shop page loads with all products). Also there is "[invalid name]" over the widget, I saw that I need a field name somewhere but where?
Hello, I am currently trying to implement the filter-functionality into my SHOP project, I have a product model that has a many2many relation to a catchphrase model. My filter looks like this: (same as docs)
the widget works fine, only the catchphrases that are currently used by products get displayed, but when I click on one of them the site reloads and nothing happens. (Also when I use "/?catchphrases", the shop page loads with all products). Also there is "[invalid name]" over the widget, I saw that I need a field name somewhere but where?
everything gets loaded correctly (angular modules etc.) but I cannot figure out why it is not filtering my products.
Thanks a lot for help in advance!