prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Keep html time field optional even if a DateTimeField is set to be required
  Time is optional in the backend but the html input field still gets the required attribute if the the DateTimeField is initializes with `required=True`
  The time Widget should always be initialized without required.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `adhocracy4/forms/widgets.py`
  Content:
  ```
  1 import datetime
  2 
  3 from django.contrib.staticfiles.storage import staticfiles_storage
  4 from django.forms import widgets as form_widgets
  5 from django.template.loader import render_to_string
  6 from django.utils.timezone import localtime
  7 
  8 
  9 class DateTimeInput(form_widgets.SplitDateTimeWidget):
  10     def __init__(self, time_label='', time_default=None, *args, **kwargs):
  11         super().__init__(*args, **kwargs)
  12         self.time_label = time_label
  13         self.time_default = time_default or datetime.time(hour=0, minute=0)
  14 
  15     class Media:
  16         js = (
  17             staticfiles_storage.url('datepicker.js'),
  18         )
  19         css = {'all': [
  20             staticfiles_storage.url('datepicker.css'),
  21         ]}
  22 
  23     def render(self, name, value, attrs=None):
  24         date_attrs = self.build_attrs(attrs)
  25         date_attrs.update({
  26             'class': 'datepicker',
  27             'placeholder': self.widgets[0].format_value(datetime.date.today()),
  28             'id': attrs['id'] + '_date'
  29         })
  30         time_attrs = self.build_attrs(attrs)
  31         time_attrs.update({
  32             'class': 'timepicker',
  33             'placeholder': self.widgets[1].format_value(
  34                 self.get_default_time()),
  35             'id': attrs['id'] + '_time'
  36         })
  37 
  38         if isinstance(value, datetime.datetime):
  39             value = localtime(value)
  40             date = value.date()
  41             time = value.time()
  42         else:
  43             # value's just a list in case of an error
  44             date = value[0] if value else None
  45             time = value[1] if value else None
  46 
  47         return render_to_string(
  48             'a4forms/datetime_input.html', {
  49                 'date': self.widgets[0].render(
  50                     name + '_0',
  51                     date,
  52                     date_attrs
  53                 ),
  54                 'time': self.widgets[1].render(
  55                     name + '_1',
  56                     time,
  57                     time_attrs
  58                 ),
  59                 'time_label': {
  60                     'label': self.time_label,
  61                     'id_for_label': attrs['id'] + '_time'
  62                 },
  63             })
  64 
  65     def id_for_label(self, id_):
  66         if id_:
  67             id_ += '_date'
  68         return id_
  69 
  70     def get_default_time(self):
  71         time_widget = self.widgets[1]
  72 
  73         if not self.time_default:
  74             return time_widget.format_value(datetime.time(hour=0, minute=0))
  75         elif isinstance(self.time_default, (datetime.time, datetime.datetime)):
  76             return time_widget.format_value(self.time_default)
  77         else:
  78             return self.time_default
  79
  ```
  --- 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/adhocracy4/forms/widgets.py b/adhocracy4/forms/widgets.py
  --- a/adhocracy4/forms/widgets.py
  +++ b/adhocracy4/forms/widgets.py
  @@ -32,7 +32,8 @@
               'class': 'timepicker',
               'placeholder': self.widgets[1].format_value(
                   self.get_default_time()),
  -            'id': attrs['id'] + '_time'
  +            'id': attrs['id'] + '_time',
  +            'required': False
           })
   
           if isinstance(value, datetime.datetime):
  
verification_info: {"golden_diff": "diff --git a/adhocracy4/forms/widgets.py b/adhocracy4/forms/widgets.py\n--- a/adhocracy4/forms/widgets.py\n+++ b/adhocracy4/forms/widgets.py\n@@ -32,7 +32,8 @@\n             'class': 'timepicker',\n             'placeholder': self.widgets[1].format_value(\n                 self.get_default_time()),\n-            'id': attrs['id'] + '_time'\n+            'id': attrs['id'] + '_time',\n+            'required': False\n         })\n \n         if isinstance(value, datetime.datetime):\n", "issue": "Keep html time field optional even if a DateTimeField is set to be required\nTime is optional in the backend but the html input field still gets the required attribute if the the DateTimeField is initializes with `required=True`\r\nThe time Widget should always be initialized without required.\n", "before_files": [{"content": "import datetime\n\nfrom django.contrib.staticfiles.storage import staticfiles_storage\nfrom django.forms import widgets as form_widgets\nfrom django.template.loader import render_to_string\nfrom django.utils.timezone import localtime\n\n\nclass DateTimeInput(form_widgets.SplitDateTimeWidget):\n    def __init__(self, time_label='', time_default=None, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.time_label = time_label\n        self.time_default = time_default or datetime.time(hour=0, minute=0)\n\n    class Media:\n        js = (\n            staticfiles_storage.url('datepicker.js'),\n        )\n        css = {'all': [\n            staticfiles_storage.url('datepicker.css'),\n        ]}\n\n    def render(self, name, value, attrs=None):\n        date_attrs = self.build_attrs(attrs)\n        date_attrs.update({\n            'class': 'datepicker',\n            'placeholder': self.widgets[0].format_value(datetime.date.today()),\n            'id': attrs['id'] + '_date'\n        })\n        time_attrs = self.build_attrs(attrs)\n        time_attrs.update({\n            'class': 'timepicker',\n            'placeholder': self.widgets[1].format_value(\n                self.get_default_time()),\n            'id': attrs['id'] + '_time'\n        })\n\n        if isinstance(value, datetime.datetime):\n            value = localtime(value)\n            date = value.date()\n            time = value.time()\n        else:\n            # value's just a list in case of an error\n            date = value[0] if value else None\n            time = value[1] if value else None\n\n        return render_to_string(\n            'a4forms/datetime_input.html', {\n                'date': self.widgets[0].render(\n                    name + '_0',\n                    date,\n                    date_attrs\n                ),\n                'time': self.widgets[1].render(\n                    name + '_1',\n                    time,\n                    time_attrs\n                ),\n                'time_label': {\n                    'label': self.time_label,\n                    'id_for_label': attrs['id'] + '_time'\n                },\n            })\n\n    def id_for_label(self, id_):\n        if id_:\n            id_ += '_date'\n        return id_\n\n    def get_default_time(self):\n        time_widget = self.widgets[1]\n\n        if not self.time_default:\n            return time_widget.format_value(datetime.time(hour=0, minute=0))\n        elif isinstance(self.time_default, (datetime.time, datetime.datetime)):\n            return time_widget.format_value(self.time_default)\n        else:\n            return self.time_default\n", "path": "adhocracy4/forms/widgets.py"}], "after_files": [{"content": "import datetime\n\nfrom django.contrib.staticfiles.storage import staticfiles_storage\nfrom django.forms import widgets as form_widgets\nfrom django.template.loader import render_to_string\nfrom django.utils.timezone import localtime\n\n\nclass DateTimeInput(form_widgets.SplitDateTimeWidget):\n    def __init__(self, time_label='', time_default=None, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.time_label = time_label\n        self.time_default = time_default or datetime.time(hour=0, minute=0)\n\n    class Media:\n        js = (\n            staticfiles_storage.url('datepicker.js'),\n        )\n        css = {'all': [\n            staticfiles_storage.url('datepicker.css'),\n        ]}\n\n    def render(self, name, value, attrs=None):\n        date_attrs = self.build_attrs(attrs)\n        date_attrs.update({\n            'class': 'datepicker',\n            'placeholder': self.widgets[0].format_value(datetime.date.today()),\n            'id': attrs['id'] + '_date'\n        })\n        time_attrs = self.build_attrs(attrs)\n        time_attrs.update({\n            'class': 'timepicker',\n            'placeholder': self.widgets[1].format_value(\n                self.get_default_time()),\n            'id': attrs['id'] + '_time',\n            'required': False\n        })\n\n        if isinstance(value, datetime.datetime):\n            value = localtime(value)\n            date = value.date()\n            time = value.time()\n        else:\n            # value's just a list in case of an error\n            date = value[0] if value else None\n            time = value[1] if value else None\n\n        return render_to_string(\n            'a4forms/datetime_input.html', {\n                'date': self.widgets[0].render(\n                    name + '_0',\n                    date,\n                    date_attrs\n                ),\n                'time': self.widgets[1].render(\n                    name + '_1',\n                    time,\n                    time_attrs\n                ),\n                'time_label': {\n                    'label': self.time_label,\n                    'id_for_label': attrs['id'] + '_time'\n                },\n            })\n\n    def id_for_label(self, id_):\n        if id_:\n            id_ += '_date'\n        return id_\n\n    def get_default_time(self):\n        time_widget = self.widgets[1]\n\n        if not self.time_default:\n            return time_widget.format_value(datetime.time(hour=0, minute=0))\n        elif isinstance(self.time_default, (datetime.time, datetime.datetime)):\n            return time_widget.format_value(self.time_default)\n        else:\n            return self.time_default\n", "path": "adhocracy4/forms/widgets.py"}]}