We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
FieldError when accessing event
### Describe the Bug
<!-- A clear and concise description of what the bug is. -->
When opening the editor page for an event, a `FieldError` occurs.


### Steps to Reproduce

1. Go to 'Events'
2. Click on an event or on the 'Create event' button
3. Error occurs (see screenshot below)

### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
Event editor page opens up


### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
Error page is loaded 


### Additional Information
<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->
![Screenshot_20200731_154413](https://user-images.githubusercontent.com/40687216/89044629-8162d500-d34a-11ea-9477-3e64e411827f.png)




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cms/views/events/event_view.py`
Content:
```
1 import logging
2 
3 from django.contrib import messages
4 from django.contrib.auth.decorators import login_required
5 from django.contrib.auth.mixins import PermissionRequiredMixin
6 from django.core.exceptions import PermissionDenied
7 from django.shortcuts import render, redirect
8 from django.utils.decorators import method_decorator
9 from django.utils.translation import ugettext as _
10 from django.views.generic import TemplateView
11 
12 from ...constants import status
13 from ...decorators import region_permission_required
14 from ...forms.events import EventForm, EventTranslationForm, RecurrenceRuleForm
15 from ...models import Region, Language, Event, EventTranslation, RecurrenceRule, POI
16 
17 logger = logging.getLogger(__name__)
18 
19 
20 @method_decorator(login_required, name="dispatch")
21 @method_decorator(region_permission_required, name="dispatch")
22 class EventView(PermissionRequiredMixin, TemplateView):
23     permission_required = "cms.view_events"
24     raise_exception = True
25 
26     template_name = "events/event_form.html"
27 
28     # pylint: disable=too-many-locals
29     def get(self, request, *args, **kwargs):
30         language = Language.objects.get(code=kwargs.get("language_code"))
31 
32         # get event and event translation objects if they exist, otherwise objects are None
33         event_instance = Event.objects.filter(id=kwargs.get("event_id")).first()
34         event_translation_instance = EventTranslation.objects.filter(
35             event=event_instance, language=language
36         ).first()
37         recurrence_rule_instance = RecurrenceRule.objects.filter(
38             event=event_instance
39         ).first()
40         poi_instance = POI.objects.filter(event=event_instance).first()
41 
42         # Make form disabled if user has no permission to edit the page
43         if not request.user.has_perm("cms.edit_events"):
44             disabled = True
45             messages.warning(
46                 request, _("You don't have the permission to edit this event.")
47             )
48         elif event_instance and event_instance.archived:
49             disabled = True
50             messages.warning(
51                 request, _("You cannot edit this event because it is archived.")
52             )
53         else:
54             disabled = False
55 
56         event_form = EventForm(instance=event_instance, disabled=disabled)
57         event_translation_form = EventTranslationForm(
58             instance=event_translation_instance, disabled=disabled
59         )
60         recurrence_rule_form = RecurrenceRuleForm(
61             instance=recurrence_rule_instance, disabled=disabled
62         )
63 
64         return render(
65             request,
66             self.template_name,
67             {
68                 "current_menu_item": "events",
69                 "event_form": event_form,
70                 "event_translation_form": event_translation_form,
71                 "recurrence_rule_form": recurrence_rule_form,
72                 "poi": poi_instance,
73                 "language": language,
74                 "languages": Region.get_current_region(request).languages
75                 if event_instance
76                 else [language],
77             },
78         )
79 
80     # pylint: disable=too-many-locals,too-many-branches
81     def post(self, request, **kwargs):
82         region = Region.objects.get(slug=kwargs.get("region_slug"))
83         language = Language.objects.get(code=kwargs.get("language_code"))
84         poi = POI.objects.filter(id=request.POST.get("poi_id")).first()
85 
86         event_instance = Event.objects.filter(id=kwargs.get("event_id")).first()
87         recurrence_rule_instance = RecurrenceRule.objects.filter(
88             event=event_instance
89         ).first()
90         event_translation_instance = EventTranslation.objects.filter(
91             event=event_instance, language=language
92         ).first()
93 
94         if not request.user.has_perm("cms.edit_events"):
95             raise PermissionDenied
96 
97         event_form = EventForm(data=request.POST, instance=event_instance,)
98         # clean data of event form to be able to pass the cleaned start date to the recurrence form for validation
99         event_form_valid = event_form.is_valid()
100         recurrence_rule_form = RecurrenceRuleForm(
101             data=request.POST,
102             instance=recurrence_rule_instance,
103             event_start_date=event_form.cleaned_data.get("start_date", None),
104         )
105         event_translation_form = EventTranslationForm(
106             data=request.POST,
107             instance=event_translation_instance,
108             region=region,
109             language=language,
110         )
111 
112         if (
113             not event_form_valid
114             or not event_translation_form.is_valid()
115             or (
116                 event_form.cleaned_data["is_recurring"]
117                 and not recurrence_rule_form.is_valid()
118             )
119         ):
120             forms = [event_form, event_translation_form]
121             if event_form.cleaned_data["is_recurring"]:
122                 forms.append(recurrence_rule_form)
123             # Add error messages
124             for form in forms:
125                 for field in form:
126                     for error in field.errors:
127                         messages.error(request, _(error))
128                 for error in form.non_field_errors():
129                     messages.error(request, _(error))
130 
131         elif (
132             not event_form.has_changed()
133             and not event_translation_form.has_changed()
134             and (
135                 not event_form.cleaned_data["is_recurring"]
136                 or not recurrence_rule_form.has_changed()
137             )
138             and poi == event_instance.location
139         ):
140 
141             messages.info(request, _("No changes detected."))
142 
143         else:
144 
145             if event_translation_form.instance.status == status.PUBLIC:
146                 if not request.user.has_perm("cms.publish_events"):
147                     raise PermissionDenied
148 
149             if event_form.cleaned_data["is_recurring"]:
150                 recurrence_rule = recurrence_rule_form.save()
151             else:
152                 recurrence_rule = None
153 
154             event = event_form.save(
155                 region=region, recurrence_rule=recurrence_rule, location=poi
156             )
157             event_translation = event_translation_form.save(
158                 event=event, user=request.user
159             )
160 
161             published = event_translation.status == status.PUBLIC
162             if not event_instance:
163                 if published:
164                     messages.success(
165                         request, _("Event was successfully created and published.")
166                     )
167                 else:
168                     messages.success(request, _("Event was successfully created."))
169                 return redirect(
170                     "edit_event",
171                     **{
172                         "event_id": event.id,
173                         "region_slug": region.slug,
174                         "language_code": language.code,
175                     }
176                 )
177             if not event_translation_instance:
178                 if published:
179                     messages.success(
180                         request,
181                         _("Event translation was successfully created and published."),
182                     )
183                 else:
184                     messages.success(
185                         request, _("Event translation was successfully created.")
186                     )
187             else:
188                 if published:
189                     messages.success(request, _("Event was successfully published."))
190                 else:
191                     messages.success(request, _("Event was successfully saved."))
192 
193         return render(
194             request,
195             self.template_name,
196             {
197                 "current_menu_item": "events",
198                 "event_form": event_form,
199                 "event_translation_form": event_translation_form,
200                 "recurrence_rule_form": recurrence_rule_form,
201                 "poi": poi,
202                 "language": language,
203                 "languages": region.languages if event_instance else [language],
204             },
205         )
206
```
--- 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()

```

diff --git a/src/cms/views/events/event_view.py b/src/cms/views/events/event_view.py
--- a/src/cms/views/events/event_view.py
+++ b/src/cms/views/events/event_view.py
@@ -37,7 +37,7 @@
         recurrence_rule_instance = RecurrenceRule.objects.filter(
             event=event_instance
         ).first()
-        poi_instance = POI.objects.filter(event=event_instance).first()
+        poi_instance = POI.objects.filter(events=event_instance).first()
 
         # Make form disabled if user has no permission to edit the page
         if not request.user.has_perm("cms.edit_events"):

{"golden_diff": "diff --git a/src/cms/views/events/event_view.py b/src/cms/views/events/event_view.py\n--- a/src/cms/views/events/event_view.py\n+++ b/src/cms/views/events/event_view.py\n@@ -37,7 +37,7 @@\n         recurrence_rule_instance = RecurrenceRule.objects.filter(\n             event=event_instance\n         ).first()\n-        poi_instance = POI.objects.filter(event=event_instance).first()\n+        poi_instance = POI.objects.filter(events=event_instance).first()\n \n         # Make form disabled if user has no permission to edit the page\n         if not request.user.has_perm(\"cms.edit_events\"):\n", "issue": "FieldError when accessing event\n### Describe the Bug\r\n<!-- A clear and concise description of what the bug is. -->\r\nWhen opening the editor page for an event, a `FieldError` occurs.\r\n\r\n\r\n### Steps to Reproduce\r\n\r\n1. Go to 'Events'\r\n2. Click on an event or on the 'Create event' button\r\n3. Error occurs (see screenshot below)\r\n\r\n### Expected Behavior\r\n<!-- A clear and concise description of what you expected to happen. -->\r\nEvent editor page opens up\r\n\r\n\r\n### Actual Behavior\r\n<!-- A clear and concise description of what actually happened. -->\r\nError page is loaded \r\n\r\n\r\n### Additional Information\r\n<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->\r\n![Screenshot_20200731_154413](https://user-images.githubusercontent.com/40687216/89044629-8162d500-d34a-11ea-9477-3e64e411827f.png)\r\n\r\n\r\n\n", "before_files": [{"content": "import logging\n\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.contrib.auth.mixins import PermissionRequiredMixin\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import render, redirect\nfrom django.utils.decorators import method_decorator\nfrom django.utils.translation import ugettext as _\nfrom django.views.generic import TemplateView\n\nfrom ...constants import status\nfrom ...decorators import region_permission_required\nfrom ...forms.events import EventForm, EventTranslationForm, RecurrenceRuleForm\nfrom ...models import Region, Language, Event, EventTranslation, RecurrenceRule, POI\n\nlogger = logging.getLogger(__name__)\n\n\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(region_permission_required, name=\"dispatch\")\nclass EventView(PermissionRequiredMixin, TemplateView):\n    permission_required = \"cms.view_events\"\n    raise_exception = True\n\n    template_name = \"events/event_form.html\"\n\n    # pylint: disable=too-many-locals\n    def get(self, request, *args, **kwargs):\n        language = Language.objects.get(code=kwargs.get(\"language_code\"))\n\n        # get event and event translation objects if they exist, otherwise objects are None\n        event_instance = Event.objects.filter(id=kwargs.get(\"event_id\")).first()\n        event_translation_instance = EventTranslation.objects.filter(\n            event=event_instance, language=language\n        ).first()\n        recurrence_rule_instance = RecurrenceRule.objects.filter(\n            event=event_instance\n        ).first()\n        poi_instance = POI.objects.filter(event=event_instance).first()\n\n        # Make form disabled if user has no permission to edit the page\n        if not request.user.has_perm(\"cms.edit_events\"):\n            disabled = True\n            messages.warning(\n                request, _(\"You don't have the permission to edit this event.\")\n            )\n        elif event_instance and event_instance.archived:\n            disabled = True\n            messages.warning(\n                request, _(\"You cannot edit this event because it is archived.\")\n            )\n        else:\n            disabled = False\n\n        event_form = EventForm(instance=event_instance, disabled=disabled)\n        event_translation_form = EventTranslationForm(\n            instance=event_translation_instance, disabled=disabled\n        )\n        recurrence_rule_form = RecurrenceRuleForm(\n            instance=recurrence_rule_instance, disabled=disabled\n        )\n\n        return render(\n            request,\n            self.template_name,\n            {\n                \"current_menu_item\": \"events\",\n                \"event_form\": event_form,\n                \"event_translation_form\": event_translation_form,\n                \"recurrence_rule_form\": recurrence_rule_form,\n                \"poi\": poi_instance,\n                \"language\": language,\n                \"languages\": Region.get_current_region(request).languages\n                if event_instance\n                else [language],\n            },\n        )\n\n    # pylint: disable=too-many-locals,too-many-branches\n    def post(self, request, **kwargs):\n        region = Region.objects.get(slug=kwargs.get(\"region_slug\"))\n        language = Language.objects.get(code=kwargs.get(\"language_code\"))\n        poi = POI.objects.filter(id=request.POST.get(\"poi_id\")).first()\n\n        event_instance = Event.objects.filter(id=kwargs.get(\"event_id\")).first()\n        recurrence_rule_instance = RecurrenceRule.objects.filter(\n            event=event_instance\n        ).first()\n        event_translation_instance = EventTranslation.objects.filter(\n            event=event_instance, language=language\n        ).first()\n\n        if not request.user.has_perm(\"cms.edit_events\"):\n            raise PermissionDenied\n\n        event_form = EventForm(data=request.POST, instance=event_instance,)\n        # clean data of event form to be able to pass the cleaned start date to the recurrence form for validation\n        event_form_valid = event_form.is_valid()\n        recurrence_rule_form = RecurrenceRuleForm(\n            data=request.POST,\n            instance=recurrence_rule_instance,\n            event_start_date=event_form.cleaned_data.get(\"start_date\", None),\n        )\n        event_translation_form = EventTranslationForm(\n            data=request.POST,\n            instance=event_translation_instance,\n            region=region,\n            language=language,\n        )\n\n        if (\n            not event_form_valid\n            or not event_translation_form.is_valid()\n            or (\n                event_form.cleaned_data[\"is_recurring\"]\n                and not recurrence_rule_form.is_valid()\n            )\n        ):\n            forms = [event_form, event_translation_form]\n            if event_form.cleaned_data[\"is_recurring\"]:\n                forms.append(recurrence_rule_form)\n            # Add error messages\n            for form in forms:\n                for field in form:\n                    for error in field.errors:\n                        messages.error(request, _(error))\n                for error in form.non_field_errors():\n                    messages.error(request, _(error))\n\n        elif (\n            not event_form.has_changed()\n            and not event_translation_form.has_changed()\n            and (\n                not event_form.cleaned_data[\"is_recurring\"]\n                or not recurrence_rule_form.has_changed()\n            )\n            and poi == event_instance.location\n        ):\n\n            messages.info(request, _(\"No changes detected.\"))\n\n        else:\n\n            if event_translation_form.instance.status == status.PUBLIC:\n                if not request.user.has_perm(\"cms.publish_events\"):\n                    raise PermissionDenied\n\n            if event_form.cleaned_data[\"is_recurring\"]:\n                recurrence_rule = recurrence_rule_form.save()\n            else:\n                recurrence_rule = None\n\n            event = event_form.save(\n                region=region, recurrence_rule=recurrence_rule, location=poi\n            )\n            event_translation = event_translation_form.save(\n                event=event, user=request.user\n            )\n\n            published = event_translation.status == status.PUBLIC\n            if not event_instance:\n                if published:\n                    messages.success(\n                        request, _(\"Event was successfully created and published.\")\n                    )\n                else:\n                    messages.success(request, _(\"Event was successfully created.\"))\n                return redirect(\n                    \"edit_event\",\n                    **{\n                        \"event_id\": event.id,\n                        \"region_slug\": region.slug,\n                        \"language_code\": language.code,\n                    }\n                )\n            if not event_translation_instance:\n                if published:\n                    messages.success(\n                        request,\n                        _(\"Event translation was successfully created and published.\"),\n                    )\n                else:\n                    messages.success(\n                        request, _(\"Event translation was successfully created.\")\n                    )\n            else:\n                if published:\n                    messages.success(request, _(\"Event was successfully published.\"))\n                else:\n                    messages.success(request, _(\"Event was successfully saved.\"))\n\n        return render(\n            request,\n            self.template_name,\n            {\n                \"current_menu_item\": \"events\",\n                \"event_form\": event_form,\n                \"event_translation_form\": event_translation_form,\n                \"recurrence_rule_form\": recurrence_rule_form,\n                \"poi\": poi,\n                \"language\": language,\n                \"languages\": region.languages if event_instance else [language],\n            },\n        )\n", "path": "src/cms/views/events/event_view.py"}], "after_files": [{"content": "import logging\n\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.contrib.auth.mixins import PermissionRequiredMixin\nfrom django.core.exceptions import PermissionDenied\nfrom django.shortcuts import render, redirect\nfrom django.utils.decorators import method_decorator\nfrom django.utils.translation import ugettext as _\nfrom django.views.generic import TemplateView\n\nfrom ...constants import status\nfrom ...decorators import region_permission_required\nfrom ...forms.events import EventForm, EventTranslationForm, RecurrenceRuleForm\nfrom ...models import Region, Language, Event, EventTranslation, RecurrenceRule, POI\n\nlogger = logging.getLogger(__name__)\n\n\n@method_decorator(login_required, name=\"dispatch\")\n@method_decorator(region_permission_required, name=\"dispatch\")\nclass EventView(PermissionRequiredMixin, TemplateView):\n    permission_required = \"cms.view_events\"\n    raise_exception = True\n\n    template_name = \"events/event_form.html\"\n\n    # pylint: disable=too-many-locals\n    def get(self, request, *args, **kwargs):\n        language = Language.objects.get(code=kwargs.get(\"language_code\"))\n\n        # get event and event translation objects if they exist, otherwise objects are None\n        event_instance = Event.objects.filter(id=kwargs.get(\"event_id\")).first()\n        event_translation_instance = EventTranslation.objects.filter(\n            event=event_instance, language=language\n        ).first()\n        recurrence_rule_instance = RecurrenceRule.objects.filter(\n            event=event_instance\n        ).first()\n        poi_instance = POI.objects.filter(events=event_instance).first()\n\n        # Make form disabled if user has no permission to edit the page\n        if not request.user.has_perm(\"cms.edit_events\"):\n            disabled = True\n            messages.warning(\n                request, _(\"You don't have the permission to edit this event.\")\n            )\n        elif event_instance and event_instance.archived:\n            disabled = True\n            messages.warning(\n                request, _(\"You cannot edit this event because it is archived.\")\n            )\n        else:\n            disabled = False\n\n        event_form = EventForm(instance=event_instance, disabled=disabled)\n        event_translation_form = EventTranslationForm(\n            instance=event_translation_instance, disabled=disabled\n        )\n        recurrence_rule_form = RecurrenceRuleForm(\n            instance=recurrence_rule_instance, disabled=disabled\n        )\n\n        return render(\n            request,\n            self.template_name,\n            {\n                \"current_menu_item\": \"events\",\n                \"event_form\": event_form,\n                \"event_translation_form\": event_translation_form,\n                \"recurrence_rule_form\": recurrence_rule_form,\n                \"poi\": poi_instance,\n                \"language\": language,\n                \"languages\": Region.get_current_region(request).languages\n                if event_instance\n                else [language],\n            },\n        )\n\n    # pylint: disable=too-many-locals,too-many-branches\n    def post(self, request, **kwargs):\n        region = Region.objects.get(slug=kwargs.get(\"region_slug\"))\n        language = Language.objects.get(code=kwargs.get(\"language_code\"))\n        poi = POI.objects.filter(id=request.POST.get(\"poi_id\")).first()\n\n        event_instance = Event.objects.filter(id=kwargs.get(\"event_id\")).first()\n        recurrence_rule_instance = RecurrenceRule.objects.filter(\n            event=event_instance\n        ).first()\n        event_translation_instance = EventTranslation.objects.filter(\n            event=event_instance, language=language\n        ).first()\n\n        if not request.user.has_perm(\"cms.edit_events\"):\n            raise PermissionDenied\n\n        event_form = EventForm(data=request.POST, instance=event_instance,)\n        # clean data of event form to be able to pass the cleaned start date to the recurrence form for validation\n        event_form_valid = event_form.is_valid()\n        recurrence_rule_form = RecurrenceRuleForm(\n            data=request.POST,\n            instance=recurrence_rule_instance,\n            event_start_date=event_form.cleaned_data.get(\"start_date\", None),\n        )\n        event_translation_form = EventTranslationForm(\n            data=request.POST,\n            instance=event_translation_instance,\n            region=region,\n            language=language,\n        )\n\n        if (\n            not event_form_valid\n            or not event_translation_form.is_valid()\n            or (\n                event_form.cleaned_data[\"is_recurring\"]\n                and not recurrence_rule_form.is_valid()\n            )\n        ):\n            forms = [event_form, event_translation_form]\n            if event_form.cleaned_data[\"is_recurring\"]:\n                forms.append(recurrence_rule_form)\n            # Add error messages\n            for form in forms:\n                for field in form:\n                    for error in field.errors:\n                        messages.error(request, _(error))\n                for error in form.non_field_errors():\n                    messages.error(request, _(error))\n\n        elif (\n            not event_form.has_changed()\n            and not event_translation_form.has_changed()\n            and (\n                not event_form.cleaned_data[\"is_recurring\"]\n                or not recurrence_rule_form.has_changed()\n            )\n            and poi == event_instance.location\n        ):\n\n            messages.info(request, _(\"No changes detected.\"))\n\n        else:\n\n            if event_translation_form.instance.status == status.PUBLIC:\n                if not request.user.has_perm(\"cms.publish_events\"):\n                    raise PermissionDenied\n\n            if event_form.cleaned_data[\"is_recurring\"]:\n                recurrence_rule = recurrence_rule_form.save()\n            else:\n                recurrence_rule = None\n\n            event = event_form.save(\n                region=region, recurrence_rule=recurrence_rule, location=poi\n            )\n            event_translation = event_translation_form.save(\n                event=event, user=request.user\n            )\n\n            published = event_translation.status == status.PUBLIC\n            if not event_instance:\n                if published:\n                    messages.success(\n                        request, _(\"Event was successfully created and published.\")\n                    )\n                else:\n                    messages.success(request, _(\"Event was successfully created.\"))\n                return redirect(\n                    \"edit_event\",\n                    **{\n                        \"event_id\": event.id,\n                        \"region_slug\": region.slug,\n                        \"language_code\": language.code,\n                    }\n                )\n            if not event_translation_instance:\n                if published:\n                    messages.success(\n                        request,\n                        _(\"Event translation was successfully created and published.\"),\n                    )\n                else:\n                    messages.success(\n                        request, _(\"Event translation was successfully created.\")\n                    )\n            else:\n                if published:\n                    messages.success(request, _(\"Event was successfully published.\"))\n                else:\n                    messages.success(request, _(\"Event was successfully saved.\"))\n\n        return render(\n            request,\n            self.template_name,\n            {\n                \"current_menu_item\": \"events\",\n                \"event_form\": event_form,\n                \"event_translation_form\": event_translation_form,\n                \"recurrence_rule_form\": recurrence_rule_form,\n                \"poi\": poi,\n                \"language\": language,\n                \"languages\": region.languages if event_instance else [language],\n            },\n        )\n", "path": "src/cms/views/events/event_view.py"}]}