Add site to filter

This commit is contained in:
Joseph Kennedy 2017-08-30 03:16:22 -04:00
parent ca83c32441
commit ae37155de5
2 changed files with 11 additions and 1 deletions

View File

@ -601,6 +601,16 @@ class InterfaceListFilter(django_filters.FilterSet):
name='name', name='name',
label='Device', label='Device',
) )
site_id = django_filters.ModelMultipleChoiceFilter(
queryset=Site.objects.all(),
label='Site (ID)',
)
site = django_filters.ModelMultipleChoiceFilter(
name='site__slug',
queryset=Site.objects.all(),
to_field_name='slug',
label='Site name (slug)',
)
type = django_filters.CharFilter( type = django_filters.CharFilter(
method='filter_type', method='filter_type',
label='Interface type', label='Interface type',

View File

@ -1621,7 +1621,7 @@ class InterfaceListFilterForm(BootstrapMixin, forms.Form):
model = Interface model = Interface
q = forms.CharField(required=False, label='Search') q = forms.CharField(required=False, label='Search')
site = FilterChoiceField( site = FilterChoiceField(
queryset=Site.objects.annotate(filter_count=Count('devices')), queryset=Site.objects.annotate(filter_count=Count('interfaces')),
to_field_name='slug', to_field_name='slug',
) )
#device = forms.ModelChoiceField(required=False, queryset=Device.objects.all(), to_field_name='slug') #device = forms.ModelChoiceField(required=False, queryset=Device.objects.all(), to_field_name='slug')