prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Scheduling a job in the past raises an exception
  ### NetBox version
  
  v3.4.2
  
  ### Python version
  
  3.10
  
  ### Steps to Reproduce
  
  1. Create a script
  2. Schedule it in the past
  
  ### Expected Behavior
  
  Form validation error message
  
  ### Observed Behavior
  
  ```
  Traceback (most recent call last):
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
      response = get_response(request)
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
      response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
      return self.dispatch(request, *args, **kwargs)
    File "/home/main/devel/repos/netbox/netbox/utilities/views.py", line 53, in dispatch
      return super().dispatch(request, *args, **kwargs)
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
      return handler(request, *args, **kwargs)
    File "/home/main/devel/repos/netbox/netbox/extras/views.py", line 815, in post
      elif form.is_valid():
    File "/home/main/devel/repos/netbox/netbox/utilities/forms/forms.py", line 69, in is_valid
      is_valid = super().is_valid()
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 205, in is_valid
      return self.is_bound and not self.errors
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 200, in errors
      self.full_clean()
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 437, in full_clean
      self._clean_fields()
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 455, in _clean_fields
      self.add_error(name, e)
    File "/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py", line 392, in add_error
      raise TypeError(
  TypeError: The argument `field` must be `None` when the `error` argument contains errors for multiple fields.
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `netbox/extras/forms/scripts.py`
  Content:
  ```
  1 from django import forms
  2 from django.utils import timezone
  3 from django.utils.translation import gettext as _
  4 
  5 from utilities.forms import BootstrapMixin, DateTimePicker, SelectDurationWidget
  6 
  7 __all__ = (
  8     'ScriptForm',
  9 )
  10 
  11 
  12 class ScriptForm(BootstrapMixin, forms.Form):
  13     _commit = forms.BooleanField(
  14         required=False,
  15         initial=True,
  16         label=_("Commit changes"),
  17         help_text=_("Commit changes to the database (uncheck for a dry-run)")
  18     )
  19     _schedule_at = forms.DateTimeField(
  20         required=False,
  21         widget=DateTimePicker(),
  22         label=_("Schedule at"),
  23         help_text=_("Schedule execution of script to a set time"),
  24     )
  25     _interval = forms.IntegerField(
  26         required=False,
  27         min_value=1,
  28         label=_("Recurs every"),
  29         widget=SelectDurationWidget(),
  30         help_text=_("Interval at which this script is re-run (in minutes)")
  31     )
  32 
  33     def __init__(self, *args, **kwargs):
  34         super().__init__(*args, **kwargs)
  35 
  36         # Annotate the current system time for reference
  37         now = timezone.now().strftime('%Y-%m-%d %H:%M:%S')
  38         self.fields['_schedule_at'].help_text += f' (current time: <strong>{now}</strong>)'
  39 
  40         # Move _commit and _schedule_at to the end of the form
  41         schedule_at = self.fields.pop('_schedule_at')
  42         interval = self.fields.pop('_interval')
  43         commit = self.fields.pop('_commit')
  44         self.fields['_schedule_at'] = schedule_at
  45         self.fields['_interval'] = interval
  46         self.fields['_commit'] = commit
  47 
  48     def clean__schedule_at(self):
  49         scheduled_time = self.cleaned_data['_schedule_at']
  50         if scheduled_time and scheduled_time < timezone.now():
  51             raise forms.ValidationError({
  52                 '_schedule_at': _('Scheduled time must be in the future.')
  53             })
  54 
  55         return scheduled_time
  56 
  57     @property
  58     def requires_input(self):
  59         """
  60         A boolean indicating whether the form requires user input (ignore the built-in fields).
  61         """
  62         return bool(len(self.fields) > 3)
  63
  ```
  --- 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/netbox/extras/forms/scripts.py b/netbox/extras/forms/scripts.py
  --- a/netbox/extras/forms/scripts.py
  +++ b/netbox/extras/forms/scripts.py
  @@ -48,9 +48,7 @@
       def clean__schedule_at(self):
           scheduled_time = self.cleaned_data['_schedule_at']
           if scheduled_time and scheduled_time < timezone.now():
  -            raise forms.ValidationError({
  -                '_schedule_at': _('Scheduled time must be in the future.')
  -            })
  +            raise forms.ValidationError(_('Scheduled time must be in the future.'))
   
           return scheduled_time
  
verification_info: {"golden_diff": "diff --git a/netbox/extras/forms/scripts.py b/netbox/extras/forms/scripts.py\n--- a/netbox/extras/forms/scripts.py\n+++ b/netbox/extras/forms/scripts.py\n@@ -48,9 +48,7 @@\n     def clean__schedule_at(self):\n         scheduled_time = self.cleaned_data['_schedule_at']\n         if scheduled_time and scheduled_time < timezone.now():\n-            raise forms.ValidationError({\n-                '_schedule_at': _('Scheduled time must be in the future.')\n-            })\n+            raise forms.ValidationError(_('Scheduled time must be in the future.'))\n \n         return scheduled_time\n", "issue": "Scheduling a job in the past raises an exception\n### NetBox version\n\nv3.4.2\n\n### Python version\n\n3.10\n\n### Steps to Reproduce\n\n1. Create a script\r\n2. Schedule it in the past\n\n### Expected Behavior\n\nForm validation error message\n\n### Observed Behavior\n\n```\r\nTraceback (most recent call last):\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py\", line 55, in inner\r\n    response = get_response(request)\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py\", line 197, in _get_response\r\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py\", line 103, in view\r\n    return self.dispatch(request, *args, **kwargs)\r\n  File \"/home/main/devel/repos/netbox/netbox/utilities/views.py\", line 53, in dispatch\r\n    return super().dispatch(request, *args, **kwargs)\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py\", line 142, in dispatch\r\n    return handler(request, *args, **kwargs)\r\n  File \"/home/main/devel/repos/netbox/netbox/extras/views.py\", line 815, in post\r\n    elif form.is_valid():\r\n  File \"/home/main/devel/repos/netbox/netbox/utilities/forms/forms.py\", line 69, in is_valid\r\n    is_valid = super().is_valid()\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py\", line 205, in is_valid\r\n    return self.is_bound and not self.errors\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py\", line 200, in errors\r\n    self.full_clean()\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py\", line 437, in full_clean\r\n    self._clean_fields()\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py\", line 455, in _clean_fields\r\n    self.add_error(name, e)\r\n  File \"/home/main/devel/repos/netbox/venv/lib/python3.10/site-packages/django/forms/forms.py\", line 392, in add_error\r\n    raise TypeError(\r\nTypeError: The argument `field` must be `None` when the `error` argument contains errors for multiple fields.\r\n```\n", "before_files": [{"content": "from django import forms\nfrom django.utils import timezone\nfrom django.utils.translation import gettext as _\n\nfrom utilities.forms import BootstrapMixin, DateTimePicker, SelectDurationWidget\n\n__all__ = (\n    'ScriptForm',\n)\n\n\nclass ScriptForm(BootstrapMixin, forms.Form):\n    _commit = forms.BooleanField(\n        required=False,\n        initial=True,\n        label=_(\"Commit changes\"),\n        help_text=_(\"Commit changes to the database (uncheck for a dry-run)\")\n    )\n    _schedule_at = forms.DateTimeField(\n        required=False,\n        widget=DateTimePicker(),\n        label=_(\"Schedule at\"),\n        help_text=_(\"Schedule execution of script to a set time\"),\n    )\n    _interval = forms.IntegerField(\n        required=False,\n        min_value=1,\n        label=_(\"Recurs every\"),\n        widget=SelectDurationWidget(),\n        help_text=_(\"Interval at which this script is re-run (in minutes)\")\n    )\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        # Annotate the current system time for reference\n        now = timezone.now().strftime('%Y-%m-%d %H:%M:%S')\n        self.fields['_schedule_at'].help_text += f' (current time: <strong>{now}</strong>)'\n\n        # Move _commit and _schedule_at to the end of the form\n        schedule_at = self.fields.pop('_schedule_at')\n        interval = self.fields.pop('_interval')\n        commit = self.fields.pop('_commit')\n        self.fields['_schedule_at'] = schedule_at\n        self.fields['_interval'] = interval\n        self.fields['_commit'] = commit\n\n    def clean__schedule_at(self):\n        scheduled_time = self.cleaned_data['_schedule_at']\n        if scheduled_time and scheduled_time < timezone.now():\n            raise forms.ValidationError({\n                '_schedule_at': _('Scheduled time must be in the future.')\n            })\n\n        return scheduled_time\n\n    @property\n    def requires_input(self):\n        \"\"\"\n        A boolean indicating whether the form requires user input (ignore the built-in fields).\n        \"\"\"\n        return bool(len(self.fields) > 3)\n", "path": "netbox/extras/forms/scripts.py"}], "after_files": [{"content": "from django import forms\nfrom django.utils import timezone\nfrom django.utils.translation import gettext as _\n\nfrom utilities.forms import BootstrapMixin, DateTimePicker, SelectDurationWidget\n\n__all__ = (\n    'ScriptForm',\n)\n\n\nclass ScriptForm(BootstrapMixin, forms.Form):\n    _commit = forms.BooleanField(\n        required=False,\n        initial=True,\n        label=_(\"Commit changes\"),\n        help_text=_(\"Commit changes to the database (uncheck for a dry-run)\")\n    )\n    _schedule_at = forms.DateTimeField(\n        required=False,\n        widget=DateTimePicker(),\n        label=_(\"Schedule at\"),\n        help_text=_(\"Schedule execution of script to a set time\"),\n    )\n    _interval = forms.IntegerField(\n        required=False,\n        min_value=1,\n        label=_(\"Recurs every\"),\n        widget=SelectDurationWidget(),\n        help_text=_(\"Interval at which this script is re-run (in minutes)\")\n    )\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        # Annotate the current system time for reference\n        now = timezone.now().strftime('%Y-%m-%d %H:%M:%S')\n        self.fields['_schedule_at'].help_text += f' (current time: <strong>{now}</strong>)'\n\n        # Move _commit and _schedule_at to the end of the form\n        schedule_at = self.fields.pop('_schedule_at')\n        interval = self.fields.pop('_interval')\n        commit = self.fields.pop('_commit')\n        self.fields['_schedule_at'] = schedule_at\n        self.fields['_interval'] = interval\n        self.fields['_commit'] = commit\n\n    def clean__schedule_at(self):\n        scheduled_time = self.cleaned_data['_schedule_at']\n        if scheduled_time and scheduled_time < timezone.now():\n            raise forms.ValidationError(_('Scheduled time must be in the future.'))\n\n        return scheduled_time\n\n    @property\n    def requires_input(self):\n        \"\"\"\n        A boolean indicating whether the form requires user input (ignore the built-in fields).\n        \"\"\"\n        return bool(len(self.fields) > 3)\n", "path": "netbox/extras/forms/scripts.py"}]}