prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Fix call to DurationField.from_db_value() which will be removed in Django 3.0
  Lots of such warning are output.
  
  ```
  src/tests/xmlrpc/test_testcaseplan.py::TestCasePlanGet::test_get_with_negative_case_id
    /testenv/lib/python3.7/site-packages/django/db/models/sql/compiler.py:995: RemovedInDjango30Warning: Remove the context parameter from DurationField.from_db_value(). Support for it will be removed in Django 3.0.
      RemovedInDjango30Warning,
  ```
  
  --- 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/tcms/core/models/fields.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 import datetime
  3 import six
  4 
  5 from django.core.exceptions import ValidationError
  6 from django.db.models.fields import IntegerField
  7 from django.db.models.fields import BooleanField
  8 
  9 from tcms.core.forms.fields import DurationField as DurationFormField
  10 
  11 try:
  12     from pymysql.constants import FIELD_TYPE
  13 except ImportError:
  14     # Refer to tcms/__init__.py for details.
  15     pass
  16 else:
  17     from django.db.backends.mysql.base import django_conversions
  18     django_conversions.update({FIELD_TYPE.TIME: None})
  19 
  20 
  21 class DurationField(IntegerField):
  22     """Duration field for test run
  23 
  24     Value is stored as number of seconds in database and presents in Nitrate in
  25     timedelta type.
  26 
  27     Value should also be able to be serialized to integer as seconds, and then
  28     deserialized from value of seconds.
  29     """
  30 
  31     def to_python(self, value):
  32         if isinstance(value, six.integer_types):
  33             return datetime.timedelta(seconds=value)
  34         elif isinstance(value, datetime.timedelta):
  35             return value
  36         else:
  37             raise TypeError('Unable to convert %s to timedelta.' % value)
  38 
  39     def from_db_value(self, value, expression, connection, context):
  40         if value is None:
  41             return value
  42         return datetime.timedelta(seconds=value)
  43 
  44     def get_db_prep_value(self, value, connection, prepared=True):
  45         """convert datetime.timedelta to seconds.
  46 
  47         1 day equal to 86400 seconds
  48         """
  49         if isinstance(value, datetime.timedelta):
  50             return value.seconds + (86400 * value.days)
  51         else:
  52             value = super(DurationField, self).get_db_prep_value(
  53                 value, connection, prepared)
  54             return value
  55 
  56     def formfield(self, form_class=DurationFormField, **kwargs):
  57         defaults = {'help_text': 'Enter duration in the format: DDHHMM'}
  58         defaults.update(kwargs)
  59         return form_class(**defaults)
  60 
  61 
  62 class NitrateBooleanField(BooleanField):
  63     """Custom boolean field to allow accepting arbitrary bool values"""
  64 
  65     def to_python(self, value):
  66         if value in (1, '1', 'true', 'True', True):
  67             return True
  68         if value in (0, '0', 'false', 'False', False):
  69             return False
  70         raise ValidationError(
  71             '{} is not recognized as a bool value.'.format(value))
  72
  ```
  --- 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/src/tcms/core/models/fields.py b/src/tcms/core/models/fields.py
  --- a/src/tcms/core/models/fields.py
  +++ b/src/tcms/core/models/fields.py
  @@ -36,7 +36,7 @@
           else:
               raise TypeError('Unable to convert %s to timedelta.' % value)
   
  -    def from_db_value(self, value, expression, connection, context):
  +    def from_db_value(self, value, *args, **kwargs):
           if value is None:
               return value
           return datetime.timedelta(seconds=value)
  
verification_info: {"golden_diff": "diff --git a/src/tcms/core/models/fields.py b/src/tcms/core/models/fields.py\n--- a/src/tcms/core/models/fields.py\n+++ b/src/tcms/core/models/fields.py\n@@ -36,7 +36,7 @@\n         else:\n             raise TypeError('Unable to convert %s to timedelta.' % value)\n \n-    def from_db_value(self, value, expression, connection, context):\n+    def from_db_value(self, value, *args, **kwargs):\n         if value is None:\n             return value\n         return datetime.timedelta(seconds=value)\n", "issue": "Fix call to DurationField.from_db_value() which will be removed in Django 3.0\nLots of such warning are output.\r\n\r\n```\r\nsrc/tests/xmlrpc/test_testcaseplan.py::TestCasePlanGet::test_get_with_negative_case_id\r\n  /testenv/lib/python3.7/site-packages/django/db/models/sql/compiler.py:995: RemovedInDjango30Warning: Remove the context parameter from DurationField.from_db_value(). Support for it will be removed in Django 3.0.\r\n    RemovedInDjango30Warning,\r\n```\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nimport datetime\nimport six\n\nfrom django.core.exceptions import ValidationError\nfrom django.db.models.fields import IntegerField\nfrom django.db.models.fields import BooleanField\n\nfrom tcms.core.forms.fields import DurationField as DurationFormField\n\ntry:\n    from pymysql.constants import FIELD_TYPE\nexcept ImportError:\n    # Refer to tcms/__init__.py for details.\n    pass\nelse:\n    from django.db.backends.mysql.base import django_conversions\n    django_conversions.update({FIELD_TYPE.TIME: None})\n\n\nclass DurationField(IntegerField):\n    \"\"\"Duration field for test run\n\n    Value is stored as number of seconds in database and presents in Nitrate in\n    timedelta type.\n\n    Value should also be able to be serialized to integer as seconds, and then\n    deserialized from value of seconds.\n    \"\"\"\n\n    def to_python(self, value):\n        if isinstance(value, six.integer_types):\n            return datetime.timedelta(seconds=value)\n        elif isinstance(value, datetime.timedelta):\n            return value\n        else:\n            raise TypeError('Unable to convert %s to timedelta.' % value)\n\n    def from_db_value(self, value, expression, connection, context):\n        if value is None:\n            return value\n        return datetime.timedelta(seconds=value)\n\n    def get_db_prep_value(self, value, connection, prepared=True):\n        \"\"\"convert datetime.timedelta to seconds.\n\n        1 day equal to 86400 seconds\n        \"\"\"\n        if isinstance(value, datetime.timedelta):\n            return value.seconds + (86400 * value.days)\n        else:\n            value = super(DurationField, self).get_db_prep_value(\n                value, connection, prepared)\n            return value\n\n    def formfield(self, form_class=DurationFormField, **kwargs):\n        defaults = {'help_text': 'Enter duration in the format: DDHHMM'}\n        defaults.update(kwargs)\n        return form_class(**defaults)\n\n\nclass NitrateBooleanField(BooleanField):\n    \"\"\"Custom boolean field to allow accepting arbitrary bool values\"\"\"\n\n    def to_python(self, value):\n        if value in (1, '1', 'true', 'True', True):\n            return True\n        if value in (0, '0', 'false', 'False', False):\n            return False\n        raise ValidationError(\n            '{} is not recognized as a bool value.'.format(value))\n", "path": "src/tcms/core/models/fields.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nimport datetime\nimport six\n\nfrom django.core.exceptions import ValidationError\nfrom django.db.models.fields import IntegerField\nfrom django.db.models.fields import BooleanField\n\nfrom tcms.core.forms.fields import DurationField as DurationFormField\n\ntry:\n    from pymysql.constants import FIELD_TYPE\nexcept ImportError:\n    # Refer to tcms/__init__.py for details.\n    pass\nelse:\n    from django.db.backends.mysql.base import django_conversions\n    django_conversions.update({FIELD_TYPE.TIME: None})\n\n\nclass DurationField(IntegerField):\n    \"\"\"Duration field for test run\n\n    Value is stored as number of seconds in database and presents in Nitrate in\n    timedelta type.\n\n    Value should also be able to be serialized to integer as seconds, and then\n    deserialized from value of seconds.\n    \"\"\"\n\n    def to_python(self, value):\n        if isinstance(value, six.integer_types):\n            return datetime.timedelta(seconds=value)\n        elif isinstance(value, datetime.timedelta):\n            return value\n        else:\n            raise TypeError('Unable to convert %s to timedelta.' % value)\n\n    def from_db_value(self, value, *args, **kwargs):\n        if value is None:\n            return value\n        return datetime.timedelta(seconds=value)\n\n    def get_db_prep_value(self, value, connection, prepared=True):\n        \"\"\"convert datetime.timedelta to seconds.\n\n        1 day equal to 86400 seconds\n        \"\"\"\n        if isinstance(value, datetime.timedelta):\n            return value.seconds + (86400 * value.days)\n        else:\n            value = super(DurationField, self).get_db_prep_value(\n                value, connection, prepared)\n            return value\n\n    def formfield(self, form_class=DurationFormField, **kwargs):\n        defaults = {'help_text': 'Enter duration in the format: DDHHMM'}\n        defaults.update(kwargs)\n        return form_class(**defaults)\n\n\nclass NitrateBooleanField(BooleanField):\n    \"\"\"Custom boolean field to allow accepting arbitrary bool values\"\"\"\n\n    def to_python(self, value):\n        if value in (1, '1', 'true', 'True', True):\n            return True\n        if value in (0, '0', 'false', 'False', False):\n            return False\n        raise ValidationError(\n            '{} is not recognized as a bool value.'.format(value))\n", "path": "src/tcms/core/models/fields.py"}]}