prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Unable to remove image from event in dashboard
  If an image has been selected for an event there is currently no way to remove the image after saving. 
  
  A shitty workaround is to inspect the hidden input field and set the value to an empty string.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/gallery/widgets.py`
  Content:
  ```
  1 # -*- coding: utf8 -*-
  2 #
  3 # Created by 'myth' on 10/14/15
  4 
  5 from django.conf import settings
  6 from django.core.urlresolvers import reverse_lazy
  7 from django.forms import HiddenInput, TextInput
  8 from django.forms.utils import flatatt, force_text, format_html
  9 
  10 from apps.gallery.models import ResponsiveImage
  11 
  12 
  13 WIDGET_STRING = """<br /><input{} />\r\n
  14 <div id="single-image-field-thumbnail">{}</div>
  15 <a href="#" class="btn btn-primary" id="add-responsive-image">\r\n
  16 <i class="fa fa-plus fa-lg"></i> Velg</a>\r\n
  17 <a href="{}" class="btn btn-primary" target="_blank">\r\n
  18 <i class="fa fa-image fa-lg"></i> Last opp</a><br>\r\n
  19 <div id="image-selection-wrapper">\r\n
  20 <h2 id="image-selection-title">Velg bilde</h2>\r\n
  21 <div class="row">\r\n
  22 <div class="col-md-12">\r\n
  23 <div class="input-group">\r\n
  24 <input type="text" id="image-gallery-search" class="form-control" placeholder="Skriv inn søkeord...">\r\n
  25 <span class="input-group-btn">\r\n
  26 <a class="btn btn-primary" id="image-gallery-search-button" type="button">Søk!</a>\r\n
  27 </span>\r\n
  28 </div>\r\n
  29 </div>\r\n
  30 </div>\r\n
  31 <hr />\r\n
  32 <div class="row" id="image-gallery-search-results"></div>\r\n
  33 </div>\r\n"""
  34 
  35 
  36 class SingleImageInput(HiddenInput):
  37     """
  38     SingleImageField adds wrapper HTML around the hidden input field containing the ResponsiveImage ID
  39     """
  40 
  41     def __init__(self, attrs=None):
  42         super(SingleImageInput, self).__init__(attrs)
  43         self.input_type = 'hidden'
  44 
  45     def render(self, name, value, attrs=None):
  46         """
  47         Renders this field widget as HTML
  48         :param name: Field input name
  49         :param value: Field input value
  50         :param attrs: Field input attributes
  51         :return: An HTML string representing this widget
  52         """
  53 
  54         if value is None:
  55             value = ''
  56 
  57         img_thumb = 'Det er ikke valgt noe bilde.'
  58         final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
  59         if value != '':
  60             # Only add the value attribute if the value is non-empty
  61             final_attrs['value'] = force_text(self._format_value(value))
  62             img = ResponsiveImage.objects.get(pk=value)
  63             img_thumb = format_html(
  64                 '<img src="{}" alt title="{}"/>',
  65                 settings.MEDIA_URL + str(img.thumbnail),
  66                 str(img.name),
  67                 encoding='utf-8'
  68             )
  69 
  70         upload_url = reverse_lazy('gallery_dashboard:upload')
  71 
  72         return format_html(WIDGET_STRING, flatatt(final_attrs), img_thumb, upload_url)
  73 
  74 
  75 class TagInputField(TextInput):
  76     """
  77     Adds some extras to a TextInputField to support space or comma separated tagging
  78     """
  79 
  80     def __init__(self, attrs=None):
  81         super(TagInputField, self).__init__(attrs=attrs)
  82 
  83     def render(self, name, value, attrs=None):
  84         """
  85         Renders this field widget as HTML
  86         :param name: Field input name
  87         :param value: Field input value
  88         :param attrs: Field input attributes
  89         :return: An HTML string representing this widget
  90         """
  91 
  92         return super(TagInputField, self).render(name, value, attrs=attrs)
  93
  ```
  --- 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/apps/gallery/widgets.py b/apps/gallery/widgets.py
  --- a/apps/gallery/widgets.py
  +++ b/apps/gallery/widgets.py
  @@ -15,7 +15,9 @@
   <a href="#" class="btn btn-primary" id="add-responsive-image">\r\n
   <i class="fa fa-plus fa-lg"></i> Velg</a>\r\n
   <a href="{}" class="btn btn-primary" target="_blank">\r\n
  -<i class="fa fa-image fa-lg"></i> Last opp</a><br>\r\n
  +<i class="fa fa-image fa-lg"></i> Last opp</a>\r\n
  +<a href="#" class="btn btn-danger" id="dashboard-gallery-remove-image">\r\n
  +<i class="fa fa-times fa-lg"></i> Fjern bilde</a><br>\r\n
   <div id="image-selection-wrapper">\r\n
   <h2 id="image-selection-title">Velg bilde</h2>\r\n
   <div class="row">\r\n
  
verification_info: {"golden_diff": "diff --git a/apps/gallery/widgets.py b/apps/gallery/widgets.py\n--- a/apps/gallery/widgets.py\n+++ b/apps/gallery/widgets.py\n@@ -15,7 +15,9 @@\n <a href=\"#\" class=\"btn btn-primary\" id=\"add-responsive-image\">\\r\\n\n <i class=\"fa fa-plus fa-lg\"></i> Velg</a>\\r\\n\n <a href=\"{}\" class=\"btn btn-primary\" target=\"_blank\">\\r\\n\n-<i class=\"fa fa-image fa-lg\"></i> Last opp</a><br>\\r\\n\n+<i class=\"fa fa-image fa-lg\"></i> Last opp</a>\\r\\n\n+<a href=\"#\" class=\"btn btn-danger\" id=\"dashboard-gallery-remove-image\">\\r\\n\n+<i class=\"fa fa-times fa-lg\"></i> Fjern bilde</a><br>\\r\\n\n <div id=\"image-selection-wrapper\">\\r\\n\n <h2 id=\"image-selection-title\">Velg bilde</h2>\\r\\n\n <div class=\"row\">\\r\\n\n", "issue": "Unable to remove image from event in dashboard\nIf an image has been selected for an event there is currently no way to remove the image after saving. \r\n\r\nA shitty workaround is to inspect the hidden input field and set the value to an empty string.\n", "before_files": [{"content": "# -*- coding: utf8 -*-\n#\n# Created by 'myth' on 10/14/15\n\nfrom django.conf import settings\nfrom django.core.urlresolvers import reverse_lazy\nfrom django.forms import HiddenInput, TextInput\nfrom django.forms.utils import flatatt, force_text, format_html\n\nfrom apps.gallery.models import ResponsiveImage\n\n\nWIDGET_STRING = \"\"\"<br /><input{} />\\r\\n\n<div id=\"single-image-field-thumbnail\">{}</div>\n<a href=\"#\" class=\"btn btn-primary\" id=\"add-responsive-image\">\\r\\n\n<i class=\"fa fa-plus fa-lg\"></i> Velg</a>\\r\\n\n<a href=\"{}\" class=\"btn btn-primary\" target=\"_blank\">\\r\\n\n<i class=\"fa fa-image fa-lg\"></i> Last opp</a><br>\\r\\n\n<div id=\"image-selection-wrapper\">\\r\\n\n<h2 id=\"image-selection-title\">Velg bilde</h2>\\r\\n\n<div class=\"row\">\\r\\n\n<div class=\"col-md-12\">\\r\\n\n<div class=\"input-group\">\\r\\n\n<input type=\"text\" id=\"image-gallery-search\" class=\"form-control\" placeholder=\"Skriv inn s\u00f8keord...\">\\r\\n\n<span class=\"input-group-btn\">\\r\\n\n<a class=\"btn btn-primary\" id=\"image-gallery-search-button\" type=\"button\">S\u00f8k!</a>\\r\\n\n</span>\\r\\n\n</div>\\r\\n\n</div>\\r\\n\n</div>\\r\\n\n<hr />\\r\\n\n<div class=\"row\" id=\"image-gallery-search-results\"></div>\\r\\n\n</div>\\r\\n\"\"\"\n\n\nclass SingleImageInput(HiddenInput):\n    \"\"\"\n    SingleImageField adds wrapper HTML around the hidden input field containing the ResponsiveImage ID\n    \"\"\"\n\n    def __init__(self, attrs=None):\n        super(SingleImageInput, self).__init__(attrs)\n        self.input_type = 'hidden'\n\n    def render(self, name, value, attrs=None):\n        \"\"\"\n        Renders this field widget as HTML\n        :param name: Field input name\n        :param value: Field input value\n        :param attrs: Field input attributes\n        :return: An HTML string representing this widget\n        \"\"\"\n\n        if value is None:\n            value = ''\n\n        img_thumb = 'Det er ikke valgt noe bilde.'\n        final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)\n        if value != '':\n            # Only add the value attribute if the value is non-empty\n            final_attrs['value'] = force_text(self._format_value(value))\n            img = ResponsiveImage.objects.get(pk=value)\n            img_thumb = format_html(\n                '<img src=\"{}\" alt title=\"{}\"/>',\n                settings.MEDIA_URL + str(img.thumbnail),\n                str(img.name),\n                encoding='utf-8'\n            )\n\n        upload_url = reverse_lazy('gallery_dashboard:upload')\n\n        return format_html(WIDGET_STRING, flatatt(final_attrs), img_thumb, upload_url)\n\n\nclass TagInputField(TextInput):\n    \"\"\"\n    Adds some extras to a TextInputField to support space or comma separated tagging\n    \"\"\"\n\n    def __init__(self, attrs=None):\n        super(TagInputField, self).__init__(attrs=attrs)\n\n    def render(self, name, value, attrs=None):\n        \"\"\"\n        Renders this field widget as HTML\n        :param name: Field input name\n        :param value: Field input value\n        :param attrs: Field input attributes\n        :return: An HTML string representing this widget\n        \"\"\"\n\n        return super(TagInputField, self).render(name, value, attrs=attrs)\n", "path": "apps/gallery/widgets.py"}], "after_files": [{"content": "# -*- coding: utf8 -*-\n#\n# Created by 'myth' on 10/14/15\n\nfrom django.conf import settings\nfrom django.core.urlresolvers import reverse_lazy\nfrom django.forms import HiddenInput, TextInput\nfrom django.forms.utils import flatatt, force_text, format_html\n\nfrom apps.gallery.models import ResponsiveImage\n\n\nWIDGET_STRING = \"\"\"<br /><input{} />\\r\\n\n<div id=\"single-image-field-thumbnail\">{}</div>\n<a href=\"#\" class=\"btn btn-primary\" id=\"add-responsive-image\">\\r\\n\n<i class=\"fa fa-plus fa-lg\"></i> Velg</a>\\r\\n\n<a href=\"{}\" class=\"btn btn-primary\" target=\"_blank\">\\r\\n\n<i class=\"fa fa-image fa-lg\"></i> Last opp</a>\\r\\n\n<a href=\"#\" class=\"btn btn-danger\" id=\"dashboard-gallery-remove-image\">\\r\\n\n<i class=\"fa fa-times fa-lg\"></i> Fjern bilde</a><br>\\r\\n\n<div id=\"image-selection-wrapper\">\\r\\n\n<h2 id=\"image-selection-title\">Velg bilde</h2>\\r\\n\n<div class=\"row\">\\r\\n\n<div class=\"col-md-12\">\\r\\n\n<div class=\"input-group\">\\r\\n\n<input type=\"text\" id=\"image-gallery-search\" class=\"form-control\" placeholder=\"Skriv inn s\u00f8keord...\">\\r\\n\n<span class=\"input-group-btn\">\\r\\n\n<a class=\"btn btn-primary\" id=\"image-gallery-search-button\" type=\"button\">S\u00f8k!</a>\\r\\n\n</span>\\r\\n\n</div>\\r\\n\n</div>\\r\\n\n</div>\\r\\n\n<hr />\\r\\n\n<div class=\"row\" id=\"image-gallery-search-results\"></div>\\r\\n\n</div>\\r\\n\"\"\"\n\n\nclass SingleImageInput(HiddenInput):\n    \"\"\"\n    SingleImageField adds wrapper HTML around the hidden input field containing the ResponsiveImage ID\n    \"\"\"\n\n    def __init__(self, attrs=None):\n        super(SingleImageInput, self).__init__(attrs)\n        self.input_type = 'hidden'\n\n    def render(self, name, value, attrs=None):\n        \"\"\"\n        Renders this field widget as HTML\n        :param name: Field input name\n        :param value: Field input value\n        :param attrs: Field input attributes\n        :return: An HTML string representing this widget\n        \"\"\"\n\n        if value is None:\n            value = ''\n\n        img_thumb = 'Det er ikke valgt noe bilde.'\n        final_attrs = self.build_attrs(attrs, type=self.input_type, name=name)\n        if value != '':\n            # Only add the value attribute if the value is non-empty\n            final_attrs['value'] = force_text(self._format_value(value))\n            img = ResponsiveImage.objects.get(pk=value)\n            img_thumb = format_html(\n                '<img src=\"{}\" alt title=\"{}\"/>',\n                settings.MEDIA_URL + str(img.thumbnail),\n                str(img.name),\n                encoding='utf-8'\n            )\n\n        upload_url = reverse_lazy('gallery_dashboard:upload')\n\n        return format_html(WIDGET_STRING, flatatt(final_attrs), img_thumb, upload_url)\n\n\nclass TagInputField(TextInput):\n    \"\"\"\n    Adds some extras to a TextInputField to support space or comma separated tagging\n    \"\"\"\n\n    def __init__(self, attrs=None):\n        super(TagInputField, self).__init__(attrs=attrs)\n\n    def render(self, name, value, attrs=None):\n        \"\"\"\n        Renders this field widget as HTML\n        :param name: Field input name\n        :param value: Field input value\n        :param attrs: Field input attributes\n        :return: An HTML string representing this widget\n        \"\"\"\n\n        return super(TagInputField, self).render(name, value, attrs=attrs)\n", "path": "apps/gallery/widgets.py"}]}