diff --git a/geotrek/maintenance/filters.py b/geotrek/maintenance/filters.py index 041bbbc2f8..7234b5932e 100644 --- a/geotrek/maintenance/filters.py +++ b/geotrek/maintenance/filters.py @@ -146,6 +146,10 @@ class Meta(StructureRelatedFilterSet.Meta): 'status', 'type', 'stake', 'subcontracting', 'project', 'on', ] + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.form.fields['year'].choices = Intervention.objects.year_choices() + class ProjectFilterSet(StructureRelatedFilterSet): bbox = PythonPolygonFilter(field_name='geom') @@ -170,3 +174,7 @@ def filter_year(self, qs, name, values): for value in values: q |= Q(begin_year__lte=value, end_year__gte=value) return qs.filter(q) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.form.fields['year'].choices = Project.objects.year_choices()