prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Outdoor - Orientations
  - [x] Ajouter les noms des champs dans les filtres
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `mapentity/filters.py`
  Content:
  ```
  1 from django.db.models.fields.related import ManyToOneRel
  2 from django.conf import settings
  3 
  4 from django_filters import FilterSet, Filter
  5 from django_filters.filterset import get_model_field
  6 from django.contrib.gis import forms
  7 
  8 from .settings import app_settings, API_SRID
  9 from .widgets import HiddenGeometryWidget
  10 
  11 
  12 class PolygonFilter(Filter):
  13 
  14     field_class = forms.PolygonField
  15 
  16     def __init__(self, *args, **kwargs):
  17         kwargs.setdefault('field_name', app_settings['GEOM_FIELD_NAME'])
  18         kwargs.setdefault('widget', HiddenGeometryWidget)
  19         kwargs.setdefault('lookup_expr', 'intersects')
  20         super(PolygonFilter, self).__init__(*args, **kwargs)
  21 
  22 
  23 class PythonPolygonFilter(PolygonFilter):
  24 
  25     def filter(self, qs, value):
  26         if not value:
  27             return qs
  28         if not value.srid:
  29             value.srid = API_SRID
  30         value.transform(settings.SRID)
  31         filtered = []
  32         for o in qs.all():
  33             geom = getattr(o, self.field_name)
  34             if geom and geom.valid and not geom.empty:
  35                 if getattr(geom, self.lookup_expr)(value):
  36                     filtered.append(o.pk)
  37             else:
  38                 filtered.append(o.pk)
  39         return qs.filter(pk__in=filtered)
  40 
  41 
  42 class BaseMapEntityFilterSet(FilterSet):
  43     def __init__(self, *args, **kwargs):
  44         super(BaseMapEntityFilterSet, self).__init__(*args, **kwargs)
  45         self.__bypass_labels()
  46 
  47     def __bypass_labels(self):
  48         """
  49         These hacks allow to bypass field labels. Using either placeholders,
  50         empty choices label, etc. This allows to greatly save space in form layout,
  51         which is required for concise filter forms.
  52         """
  53         for fieldname in self.base_filters.keys():
  54             field = self.form.fields[fieldname]
  55             if isinstance(field, forms.MultiValueField):
  56                 for i, widget in enumerate(field.widget.widgets):
  57                     self.__set_placeholder(field.fields[i], widget)
  58             elif isinstance(field, forms.ChoiceField):
  59                 field.empty_label = field.label
  60                 self.__set_placeholder(field, field.widget)
  61             elif isinstance(field, forms.NullBooleanField):
  62                 choices = [(u'1', field.label)] + field.widget.choices[1:]
  63                 field.widget.choices = choices
  64                 self.__set_placeholder(field, field.widget)
  65             else:
  66                 self.__set_placeholder(field, field.widget)
  67 
  68     def __set_placeholder(self, field, widget):
  69         field.help_text = ''  # Hide help text
  70         widget.attrs['placeholder'] = field.label
  71         widget.attrs['data-placeholder'] = field.label
  72         widget.attrs['title'] = field.label
  73         widget.attrs['data-label'] = field.label
  74 
  75     @classmethod
  76     def add_filter(cls, name, filter_=None):
  77         field = get_model_field(cls._meta.model, name)
  78         if filter_ is None:
  79             if isinstance(field, ManyToOneRel):
  80                 filter_ = cls.filter_for_reverse_field(field, name)
  81             else:
  82                 filter_ = cls.filter_for_field(field, name)
  83         cls.base_filters[name] = filter_
  84 
  85     @classmethod
  86     def add_filters(cls, filters):
  87         for name, filter_ in filters.items():
  88             filter_.field_name = name
  89             cls.add_filter(name, filter_)
  90 
  91 
  92 class MapEntityFilterSet(BaseMapEntityFilterSet):
  93     bbox = PolygonFilter()
  94 
  95     class Meta:
  96         fields = ['bbox']
  97
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/mapentity/filters.py b/mapentity/filters.py
  --- a/mapentity/filters.py
  +++ b/mapentity/filters.py
  @@ -2,6 +2,7 @@
   from django.conf import settings
   
   from django_filters import FilterSet, Filter
  +from django_filters.fields import ChoiceField
   from django_filters.filterset import get_model_field
   from django.contrib.gis import forms
   
  @@ -42,6 +43,9 @@
   class BaseMapEntityFilterSet(FilterSet):
       def __init__(self, *args, **kwargs):
           super(BaseMapEntityFilterSet, self).__init__(*args, **kwargs)
  +        for filter_ in self.filters.values():
  +            if filter_.field_class == ChoiceField:
  +                filter_.extra.setdefault('empty_label', filter_.label)
           self.__bypass_labels()
   
       def __bypass_labels(self):
  
verification_info: {"golden_diff": "diff --git a/mapentity/filters.py b/mapentity/filters.py\n--- a/mapentity/filters.py\n+++ b/mapentity/filters.py\n@@ -2,6 +2,7 @@\n from django.conf import settings\n \n from django_filters import FilterSet, Filter\n+from django_filters.fields import ChoiceField\n from django_filters.filterset import get_model_field\n from django.contrib.gis import forms\n \n@@ -42,6 +43,9 @@\n class BaseMapEntityFilterSet(FilterSet):\n     def __init__(self, *args, **kwargs):\n         super(BaseMapEntityFilterSet, self).__init__(*args, **kwargs)\n+        for filter_ in self.filters.values():\n+            if filter_.field_class == ChoiceField:\n+                filter_.extra.setdefault('empty_label', filter_.label)\n         self.__bypass_labels()\n \n     def __bypass_labels(self):\n", "issue": "Outdoor - Orientations\n- [x] Ajouter les noms des champs dans les filtres\n", "before_files": [{"content": "from django.db.models.fields.related import ManyToOneRel\nfrom django.conf import settings\n\nfrom django_filters import FilterSet, Filter\nfrom django_filters.filterset import get_model_field\nfrom django.contrib.gis import forms\n\nfrom .settings import app_settings, API_SRID\nfrom .widgets import HiddenGeometryWidget\n\n\nclass PolygonFilter(Filter):\n\n    field_class = forms.PolygonField\n\n    def __init__(self, *args, **kwargs):\n        kwargs.setdefault('field_name', app_settings['GEOM_FIELD_NAME'])\n        kwargs.setdefault('widget', HiddenGeometryWidget)\n        kwargs.setdefault('lookup_expr', 'intersects')\n        super(PolygonFilter, self).__init__(*args, **kwargs)\n\n\nclass PythonPolygonFilter(PolygonFilter):\n\n    def filter(self, qs, value):\n        if not value:\n            return qs\n        if not value.srid:\n            value.srid = API_SRID\n        value.transform(settings.SRID)\n        filtered = []\n        for o in qs.all():\n            geom = getattr(o, self.field_name)\n            if geom and geom.valid and not geom.empty:\n                if getattr(geom, self.lookup_expr)(value):\n                    filtered.append(o.pk)\n            else:\n                filtered.append(o.pk)\n        return qs.filter(pk__in=filtered)\n\n\nclass BaseMapEntityFilterSet(FilterSet):\n    def __init__(self, *args, **kwargs):\n        super(BaseMapEntityFilterSet, self).__init__(*args, **kwargs)\n        self.__bypass_labels()\n\n    def __bypass_labels(self):\n        \"\"\"\n        These hacks allow to bypass field labels. Using either placeholders,\n        empty choices label, etc. This allows to greatly save space in form layout,\n        which is required for concise filter forms.\n        \"\"\"\n        for fieldname in self.base_filters.keys():\n            field = self.form.fields[fieldname]\n            if isinstance(field, forms.MultiValueField):\n                for i, widget in enumerate(field.widget.widgets):\n                    self.__set_placeholder(field.fields[i], widget)\n            elif isinstance(field, forms.ChoiceField):\n                field.empty_label = field.label\n                self.__set_placeholder(field, field.widget)\n            elif isinstance(field, forms.NullBooleanField):\n                choices = [(u'1', field.label)] + field.widget.choices[1:]\n                field.widget.choices = choices\n                self.__set_placeholder(field, field.widget)\n            else:\n                self.__set_placeholder(field, field.widget)\n\n    def __set_placeholder(self, field, widget):\n        field.help_text = ''  # Hide help text\n        widget.attrs['placeholder'] = field.label\n        widget.attrs['data-placeholder'] = field.label\n        widget.attrs['title'] = field.label\n        widget.attrs['data-label'] = field.label\n\n    @classmethod\n    def add_filter(cls, name, filter_=None):\n        field = get_model_field(cls._meta.model, name)\n        if filter_ is None:\n            if isinstance(field, ManyToOneRel):\n                filter_ = cls.filter_for_reverse_field(field, name)\n            else:\n                filter_ = cls.filter_for_field(field, name)\n        cls.base_filters[name] = filter_\n\n    @classmethod\n    def add_filters(cls, filters):\n        for name, filter_ in filters.items():\n            filter_.field_name = name\n            cls.add_filter(name, filter_)\n\n\nclass MapEntityFilterSet(BaseMapEntityFilterSet):\n    bbox = PolygonFilter()\n\n    class Meta:\n        fields = ['bbox']\n", "path": "mapentity/filters.py"}], "after_files": [{"content": "from django.db.models.fields.related import ManyToOneRel\nfrom django.conf import settings\n\nfrom django_filters import FilterSet, Filter\nfrom django_filters.fields import ChoiceField\nfrom django_filters.filterset import get_model_field\nfrom django.contrib.gis import forms\n\nfrom .settings import app_settings, API_SRID\nfrom .widgets import HiddenGeometryWidget\n\n\nclass PolygonFilter(Filter):\n\n    field_class = forms.PolygonField\n\n    def __init__(self, *args, **kwargs):\n        kwargs.setdefault('field_name', app_settings['GEOM_FIELD_NAME'])\n        kwargs.setdefault('widget', HiddenGeometryWidget)\n        kwargs.setdefault('lookup_expr', 'intersects')\n        super(PolygonFilter, self).__init__(*args, **kwargs)\n\n\nclass PythonPolygonFilter(PolygonFilter):\n\n    def filter(self, qs, value):\n        if not value:\n            return qs\n        if not value.srid:\n            value.srid = API_SRID\n        value.transform(settings.SRID)\n        filtered = []\n        for o in qs.all():\n            geom = getattr(o, self.field_name)\n            if geom and geom.valid and not geom.empty:\n                if getattr(geom, self.lookup_expr)(value):\n                    filtered.append(o.pk)\n            else:\n                filtered.append(o.pk)\n        return qs.filter(pk__in=filtered)\n\n\nclass BaseMapEntityFilterSet(FilterSet):\n    def __init__(self, *args, **kwargs):\n        super(BaseMapEntityFilterSet, self).__init__(*args, **kwargs)\n        for filter_ in self.filters.values():\n            if filter_.field_class == ChoiceField:\n                filter_.extra.setdefault('empty_label', filter_.label)\n        self.__bypass_labels()\n\n    def __bypass_labels(self):\n        \"\"\"\n        These hacks allow to bypass field labels. Using either placeholders,\n        empty choices label, etc. This allows to greatly save space in form layout,\n        which is required for concise filter forms.\n        \"\"\"\n        for fieldname in self.base_filters.keys():\n            field = self.form.fields[fieldname]\n            if isinstance(field, forms.MultiValueField):\n                for i, widget in enumerate(field.widget.widgets):\n                    self.__set_placeholder(field.fields[i], widget)\n            elif isinstance(field, forms.ChoiceField):\n                field.empty_label = field.label\n                self.__set_placeholder(field, field.widget)\n            elif isinstance(field, forms.NullBooleanField):\n                choices = [(u'1', field.label)] + field.widget.choices[1:]\n                field.widget.choices = choices\n                self.__set_placeholder(field, field.widget)\n            else:\n                self.__set_placeholder(field, field.widget)\n\n    def __set_placeholder(self, field, widget):\n        field.help_text = ''  # Hide help text\n        widget.attrs['placeholder'] = field.label\n        widget.attrs['data-placeholder'] = field.label\n        widget.attrs['title'] = field.label\n        widget.attrs['data-label'] = field.label\n\n    @classmethod\n    def add_filter(cls, name, filter_=None):\n        field = get_model_field(cls._meta.model, name)\n        if filter_ is None:\n            if isinstance(field, ManyToOneRel):\n                filter_ = cls.filter_for_reverse_field(field, name)\n            else:\n                filter_ = cls.filter_for_field(field, name)\n        cls.base_filters[name] = filter_\n\n    @classmethod\n    def add_filters(cls, filters):\n        for name, filter_ in filters.items():\n            filter_.field_name = name\n            cls.add_filter(name, filter_)\n\n\nclass MapEntityFilterSet(BaseMapEntityFilterSet):\n    bbox = PolygonFilter()\n\n    class Meta:\n        fields = ['bbox']\n", "path": "mapentity/filters.py"}]}