We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error 500: Editing Answers.
# Problem

When I select the edit option for the answers on http://changelog.qgis.org/id/inasafe-realtime2/
Then I get error 500.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `django_project/lesson/views/answer.py`
Content:
```
1 # coding=utf-8
2 """Answer views."""
3 
4 from django.core.urlresolvers import reverse
5 from django.views.generic import (
6     CreateView,
7     DeleteView,
8     UpdateView,
9 )
10 from django.shortcuts import get_object_or_404
11 from django.utils.translation import ugettext_lazy as _
12 
13 from braces.views import LoginRequiredMixin
14 
15 from lesson.forms.answer import AnswerForm
16 from lesson.models.answer import Answer
17 from lesson.models.worksheet_question import WorksheetQuestion
18 
19 
20 class AnswerMixin(object):
21     """Mixin class to provide standard settings for Answer."""
22 
23     model = Answer
24     form_class = AnswerForm
25 
26 
27 class AnswerCreateView(
28     LoginRequiredMixin, AnswerMixin, CreateView):
29     """Create view for Answer."""
30 
31     context_object_name = 'answer'
32     template_name = 'create.html'
33     creation_label = _('Add answer')
34 
35     def get_success_url(self):
36         """Define the redirect URL
37 
38         After successful creation of the object, the User will be redirected
39         to the unapproved Version list page for the object's parent Worksheet
40 
41         :returns: URL
42         :rtype: HttpResponse
43         """
44         return reverse('worksheet-detail', kwargs={
45             'pk': self.object.question.worksheet.pk,
46             'section_slug': self.object.question.worksheet.section.slug,
47             'project_slug': self.object.question.worksheet.section.project.slug
48         })
49 
50     def get_form_kwargs(self):
51         """Get keyword arguments from form.
52 
53         :returns keyword argument from the form
54         :rtype dict
55         """
56         kwargs = super(AnswerCreateView, self).get_form_kwargs()
57         pk = self.kwargs['question_pk']
58         kwargs['question'] = get_object_or_404(WorksheetQuestion, pk=pk)
59         return kwargs
60 
61 
62 # noinspection PyAttributeOutsideInit
63 class AnswerDeleteView(
64         LoginRequiredMixin,
65         AnswerMixin,
66         DeleteView):
67     """Delete view for Answer."""
68 
69     context_object_name = 'answer'
70     template_name = 'answer/delete.html'
71 
72     def get_success_url(self):
73         """Define the redirect URL.
74 
75         After successful deletion  of the object, the User will be redirected
76         to the Certifying Organisation list page
77         for the object's parent Worksheet.
78 
79         :returns: URL
80         :rtype: HttpResponse
81         """
82         return reverse('worksheet-detail', kwargs={
83             'pk': self.object.question.worksheet.pk,
84             'section_slug': self.object.question.worksheet.section.slug,
85             'project_slug': self.object.question.worksheet.section.project.slug
86         })
87 
88 
89 # noinspection PyAttributeOutsideInit
90 class AnswerUpdateView(
91         LoginRequiredMixin,
92         AnswerMixin,
93         UpdateView):
94     """Update view for Answer."""
95 
96     context_object_name = 'answer'
97     template_name = 'update.html'
98     update_label = _('Update answer')
99 
100     def get_form_kwargs(self):
101         """Get keyword arguments from form.
102 
103         :returns keyword argument from the form
104         :rtype: dict
105         """
106         kwargs = super(AnswerUpdateView, self).get_form_kwargs()
107         answer = get_object_or_404(Answer, self.pk_url_kwarg)
108         kwargs['question'] = answer.question
109         return kwargs
110 
111     def get_success_url(self):
112         """Define the redirect URL.
113 
114         After successful update of the object, the User will be redirected to
115         the specification list page for the object's parent Worksheet.
116 
117         :returns: URL
118         :rtype: HttpResponse
119         """
120         return reverse('worksheet-detail', kwargs={
121             'pk': self.object.question.worksheet.pk,
122             'section_slug': self.object.question.worksheet.section.slug,
123             'project_slug': self.object.question.worksheet.section.project.slug
124         })
125
```
--- 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/django_project/lesson/views/answer.py b/django_project/lesson/views/answer.py
--- a/django_project/lesson/views/answer.py
+++ b/django_project/lesson/views/answer.py
@@ -104,7 +104,7 @@
         :rtype: dict
         """
         kwargs = super(AnswerUpdateView, self).get_form_kwargs()
-        answer = get_object_or_404(Answer, self.pk_url_kwarg)
+        answer = get_object_or_404(Answer, pk=kwargs['instance'].pk)
         kwargs['question'] = answer.question
         return kwargs

{"golden_diff": "diff --git a/django_project/lesson/views/answer.py b/django_project/lesson/views/answer.py\n--- a/django_project/lesson/views/answer.py\n+++ b/django_project/lesson/views/answer.py\n@@ -104,7 +104,7 @@\n         :rtype: dict\n         \"\"\"\n         kwargs = super(AnswerUpdateView, self).get_form_kwargs()\n-        answer = get_object_or_404(Answer, self.pk_url_kwarg)\n+        answer = get_object_or_404(Answer, pk=kwargs['instance'].pk)\n         kwargs['question'] = answer.question\n         return kwargs\n", "issue": "Error 500: Editing Answers.\n# Problem\r\n\r\nWhen I select the edit option for the answers on http://changelog.qgis.org/id/inasafe-realtime2/\r\nThen I get error 500.\n", "before_files": [{"content": "# coding=utf-8\n\"\"\"Answer views.\"\"\"\n\nfrom django.core.urlresolvers import reverse\nfrom django.views.generic import (\n    CreateView,\n    DeleteView,\n    UpdateView,\n)\nfrom django.shortcuts import get_object_or_404\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom braces.views import LoginRequiredMixin\n\nfrom lesson.forms.answer import AnswerForm\nfrom lesson.models.answer import Answer\nfrom lesson.models.worksheet_question import WorksheetQuestion\n\n\nclass AnswerMixin(object):\n    \"\"\"Mixin class to provide standard settings for Answer.\"\"\"\n\n    model = Answer\n    form_class = AnswerForm\n\n\nclass AnswerCreateView(\n    LoginRequiredMixin, AnswerMixin, CreateView):\n    \"\"\"Create view for Answer.\"\"\"\n\n    context_object_name = 'answer'\n    template_name = 'create.html'\n    creation_label = _('Add answer')\n\n    def get_success_url(self):\n        \"\"\"Define the redirect URL\n\n        After successful creation of the object, the User will be redirected\n        to the unapproved Version list page for the object's parent Worksheet\n\n        :returns: URL\n        :rtype: HttpResponse\n        \"\"\"\n        return reverse('worksheet-detail', kwargs={\n            'pk': self.object.question.worksheet.pk,\n            'section_slug': self.object.question.worksheet.section.slug,\n            'project_slug': self.object.question.worksheet.section.project.slug\n        })\n\n    def get_form_kwargs(self):\n        \"\"\"Get keyword arguments from form.\n\n        :returns keyword argument from the form\n        :rtype dict\n        \"\"\"\n        kwargs = super(AnswerCreateView, self).get_form_kwargs()\n        pk = self.kwargs['question_pk']\n        kwargs['question'] = get_object_or_404(WorksheetQuestion, pk=pk)\n        return kwargs\n\n\n# noinspection PyAttributeOutsideInit\nclass AnswerDeleteView(\n        LoginRequiredMixin,\n        AnswerMixin,\n        DeleteView):\n    \"\"\"Delete view for Answer.\"\"\"\n\n    context_object_name = 'answer'\n    template_name = 'answer/delete.html'\n\n    def get_success_url(self):\n        \"\"\"Define the redirect URL.\n\n        After successful deletion  of the object, the User will be redirected\n        to the Certifying Organisation list page\n        for the object's parent Worksheet.\n\n        :returns: URL\n        :rtype: HttpResponse\n        \"\"\"\n        return reverse('worksheet-detail', kwargs={\n            'pk': self.object.question.worksheet.pk,\n            'section_slug': self.object.question.worksheet.section.slug,\n            'project_slug': self.object.question.worksheet.section.project.slug\n        })\n\n\n# noinspection PyAttributeOutsideInit\nclass AnswerUpdateView(\n        LoginRequiredMixin,\n        AnswerMixin,\n        UpdateView):\n    \"\"\"Update view for Answer.\"\"\"\n\n    context_object_name = 'answer'\n    template_name = 'update.html'\n    update_label = _('Update answer')\n\n    def get_form_kwargs(self):\n        \"\"\"Get keyword arguments from form.\n\n        :returns keyword argument from the form\n        :rtype: dict\n        \"\"\"\n        kwargs = super(AnswerUpdateView, self).get_form_kwargs()\n        answer = get_object_or_404(Answer, self.pk_url_kwarg)\n        kwargs['question'] = answer.question\n        return kwargs\n\n    def get_success_url(self):\n        \"\"\"Define the redirect URL.\n\n        After successful update of the object, the User will be redirected to\n        the specification list page for the object's parent Worksheet.\n\n        :returns: URL\n        :rtype: HttpResponse\n        \"\"\"\n        return reverse('worksheet-detail', kwargs={\n            'pk': self.object.question.worksheet.pk,\n            'section_slug': self.object.question.worksheet.section.slug,\n            'project_slug': self.object.question.worksheet.section.project.slug\n        })\n", "path": "django_project/lesson/views/answer.py"}], "after_files": [{"content": "# coding=utf-8\n\"\"\"Answer views.\"\"\"\n\nfrom django.core.urlresolvers import reverse\nfrom django.views.generic import (\n    CreateView,\n    DeleteView,\n    UpdateView,\n)\nfrom django.shortcuts import get_object_or_404\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom braces.views import LoginRequiredMixin\n\nfrom lesson.forms.answer import AnswerForm\nfrom lesson.models.answer import Answer\nfrom lesson.models.worksheet_question import WorksheetQuestion\n\n\nclass AnswerMixin(object):\n    \"\"\"Mixin class to provide standard settings for Answer.\"\"\"\n\n    model = Answer\n    form_class = AnswerForm\n\n\nclass AnswerCreateView(\n    LoginRequiredMixin, AnswerMixin, CreateView):\n    \"\"\"Create view for Answer.\"\"\"\n\n    context_object_name = 'answer'\n    template_name = 'create.html'\n    creation_label = _('Add answer')\n\n    def get_success_url(self):\n        \"\"\"Define the redirect URL\n\n        After successful creation of the object, the User will be redirected\n        to the unapproved Version list page for the object's parent Worksheet\n\n        :returns: URL\n        :rtype: HttpResponse\n        \"\"\"\n        return reverse('worksheet-detail', kwargs={\n            'pk': self.object.question.worksheet.pk,\n            'section_slug': self.object.question.worksheet.section.slug,\n            'project_slug': self.object.question.worksheet.section.project.slug\n        })\n\n    def get_form_kwargs(self):\n        \"\"\"Get keyword arguments from form.\n\n        :returns keyword argument from the form\n        :rtype dict\n        \"\"\"\n        kwargs = super(AnswerCreateView, self).get_form_kwargs()\n        pk = self.kwargs['question_pk']\n        kwargs['question'] = get_object_or_404(WorksheetQuestion, pk=pk)\n        return kwargs\n\n\n# noinspection PyAttributeOutsideInit\nclass AnswerDeleteView(\n        LoginRequiredMixin,\n        AnswerMixin,\n        DeleteView):\n    \"\"\"Delete view for Answer.\"\"\"\n\n    context_object_name = 'answer'\n    template_name = 'answer/delete.html'\n\n    def get_success_url(self):\n        \"\"\"Define the redirect URL.\n\n        After successful deletion  of the object, the User will be redirected\n        to the Certifying Organisation list page\n        for the object's parent Worksheet.\n\n        :returns: URL\n        :rtype: HttpResponse\n        \"\"\"\n        return reverse('worksheet-detail', kwargs={\n            'pk': self.object.question.worksheet.pk,\n            'section_slug': self.object.question.worksheet.section.slug,\n            'project_slug': self.object.question.worksheet.section.project.slug\n        })\n\n\n# noinspection PyAttributeOutsideInit\nclass AnswerUpdateView(\n        LoginRequiredMixin,\n        AnswerMixin,\n        UpdateView):\n    \"\"\"Update view for Answer.\"\"\"\n\n    context_object_name = 'answer'\n    template_name = 'update.html'\n    update_label = _('Update answer')\n\n    def get_form_kwargs(self):\n        \"\"\"Get keyword arguments from form.\n\n        :returns keyword argument from the form\n        :rtype: dict\n        \"\"\"\n        kwargs = super(AnswerUpdateView, self).get_form_kwargs()\n        answer = get_object_or_404(Answer, pk=kwargs['instance'].pk)\n        kwargs['question'] = answer.question\n        return kwargs\n\n    def get_success_url(self):\n        \"\"\"Define the redirect URL.\n\n        After successful update of the object, the User will be redirected to\n        the specification list page for the object's parent Worksheet.\n\n        :returns: URL\n        :rtype: HttpResponse\n        \"\"\"\n        return reverse('worksheet-detail', kwargs={\n            'pk': self.object.question.worksheet.pk,\n            'section_slug': self.object.question.worksheet.section.slug,\n            'project_slug': self.object.question.worksheet.section.project.slug\n        })\n", "path": "django_project/lesson/views/answer.py"}]}