# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.forms.widgets import Select
from django.utils.translation import ugettext_lazy as _
import django_filters
from djng.forms import NgModelFormMixin
from djng.styling.bootstrap3.forms import Bootstrap3Form
from myshop.models.manufacturer import Manufacturer
from myshop.models import Product


class FilterForm(NgModelFormMixin, Bootstrap3Form):
    scope_prefix = 'filters'


class ManufacturerFilterSet(django_filters.FilterSet):
    manufacturer = django_filters.ModelChoiceFilter(
        queryset=Manufacturer.objects.all(),
        widget=Select(attrs={'ng-change': 'filterChanged()'}),
        empty_label=_("Any Manufacturer"),
        help_text=_("Restrict product on this manufacturer only"),
    )

    class Meta:
        model = Product
        form = FilterForm
        fields = ['manufacturer']

    @classmethod
    def get_render_context(cls, request, queryset):
        # create filter set with bound form, to enable the selected option
        filter_set = cls(data=request.GET)

        # we only want to show manufacturers for products available in the current list view
        filter_field = filter_set.filters['manufacturer'].field
        filter_field.queryset = filter_field.queryset.filter(
            id__in=queryset.values_list('manufacturer_id'))
        return dict(filter_set=filter_set)

@@ -154,22 +154,20 @@
 zy as _%0A
-import
+from
  django_
@@ -173,16 +173,34 @@
 _filters
+ import FilterSet%0A
 %0Afrom dj
@@ -289,16 +289,61 @@
 ap3Form%0A
+%0Afrom shop.filters import ModelChoiceFilter%0A%0A
 from mys
@@ -533,31 +533,16 @@
 lterSet(
-django_filters.
 FilterSe
@@ -568,23 +568,8 @@
 r = 
-django_filters.
 Mode

use redeclared django filters with djng form fields