We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Django 2.1 compatibility
We should switch our supported Django version to the following list:
* Django 1.11 (current LTS)
* Django 2.1 (latest stable)

Current blockers:
* [x] `graphene-django` depends on an old version of `django-filters` (https://github.com/graphql-python/graphene-django/pull/492)
* [x] WeightInput passes floats to its base class which is a DecimalField
* [x] Some form widgets pass `renderer` to functions that don't expect it

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `saleor/core/weight.py`
Content:
```
1 """In Saleor we are using 'weight' instead of a 'mass'.
2 
3 For those of us who are earth-bound, weight is what we usually experience.
4 Mass is a theoretical construct.
5 Unless we are dealing with inertia and momentum, we are encountering
6 the attractive force between ourselves and the earth,
7 the isolated effects of mass alone being a little more esoteric.
8 
9 So even though mass is more fundamental, most people think
10 in terms of weight.
11 
12 In the end, it does not really matter unless you travel between
13 different planets.
14 """
15 from decimal import Decimal
16 from enum import Enum
17 
18 from django import forms
19 from django.contrib.sites.models import Site
20 from django.core.validators import MinValueValidator
21 from django.template.loader import render_to_string
22 from django.utils.translation import pgettext_lazy
23 from measurement.measures import Weight
24 
25 
26 class WeightUnits:
27     KILOGRAM = 'kg'
28     POUND = 'lb'
29     OUNCE = 'oz'
30     GRAM = 'g'
31 
32     CHOICES = [
33         (KILOGRAM, pgettext_lazy('Kilogram weight unit symbol', 'kg')),
34         (POUND, pgettext_lazy('Pound weight unit symbol', 'lb')),
35         (OUNCE, pgettext_lazy('Ounce weight unit symbol', 'oz')),
36         (GRAM, pgettext_lazy('Gram weight unit symbol', 'g'))]
37 
38 
39 WeightUnitsEnum = Enum(
40     'WeightUnitsEnum',
41     {unit: unit for unit in WeightUnits.CHOICES})
42 
43 
44 def zero_weight():
45     """Function used as a model's default."""
46     return Weight(kg=0)
47 
48 
49 def convert_weight(weight, unit):
50     # Weight amount from the Weight instance can be retrived in serveral units
51     # via its properties. eg. Weight(lb=10).kg
52     converted_weight = getattr(weight, unit)
53     return Weight(**{unit: converted_weight})
54 
55 
56 def get_default_weight_unit():
57     site = Site.objects.get_current()
58     return site.settings.default_weight_unit
59 
60 
61 class WeightInput(forms.TextInput):
62     template = 'dashboard/shipping/weight_widget.html'
63     input_type = 'number'
64 
65     def format_value(self, value):
66         if isinstance(value, Weight):
67             unit = get_default_weight_unit()
68             if value.unit != unit:
69                 value = convert_weight(value, unit)
70             return value.value
71         return value
72 
73     def render(self, name, value, attrs=None):
74         widget = super().render(name, value, attrs=attrs)
75         unit = get_default_weight_unit()
76         translated_unit = dict(WeightUnits.CHOICES)[unit]
77         return render_to_string(
78             self.template,
79             {'widget': widget, 'value': value, 'unit': translated_unit})
80 
81 
82 class WeightField(forms.DecimalField):
83     def __init__(self, *args, widget=WeightInput, min_value=0, **kwargs):
84         if isinstance(widget, type):
85             widget = widget(attrs={'type': 'number', 'step': 'any'})
86         super().__init__(*args, widget=widget, **kwargs)
87         if min_value is not None:
88             self.validators.append(MinValueValidator(min_value))
89 
90     def to_python(self, value):
91         value = super().to_python(value)
92         if value is None:
93             return value
94         unit = get_default_weight_unit()
95         return Weight(**{unit: value})
96 
97     def validate(self, weight):
98         if weight is None or weight in self.empty_values:
99             super().validate(weight)
100         else:
101             unit = get_default_weight_unit()
102             if not isinstance(weight, Weight):
103                 raise Exception(
104                     '%r is not a valid weight.' % (weight,))
105             if weight.unit != unit:
106                 raise forms.ValidationError(
107                     'Invalid unit: %r (expected %r).' % (
108                         weight.unit, unit))
109             super().validate(weight.value)
110 
111     def clean(self, value):
112         value = value_to_be_validated = self.to_python(value)
113         self.validate(value_to_be_validated)
114         if isinstance(value, Weight):
115             value_to_be_validated = Decimal(value.value)
116         # default decimal validators can be used for Weight's value only
117         self.run_validators(value_to_be_validated)
118         return value
119
```
--- 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/saleor/core/weight.py b/saleor/core/weight.py
--- a/saleor/core/weight.py
+++ b/saleor/core/weight.py
@@ -70,8 +70,8 @@
             return value.value
         return value
 
-    def render(self, name, value, attrs=None):
-        widget = super().render(name, value, attrs=attrs)
+    def render(self, name, value, attrs=None, renderer=None):
+        widget = super().render(name, value, attrs=attrs, renderer=renderer)
         unit = get_default_weight_unit()
         translated_unit = dict(WeightUnits.CHOICES)[unit]
         return render_to_string(
@@ -79,7 +79,7 @@
             {'widget': widget, 'value': value, 'unit': translated_unit})
 
 
-class WeightField(forms.DecimalField):
+class WeightField(forms.FloatField):
     def __init__(self, *args, widget=WeightInput, min_value=0, **kwargs):
         if isinstance(widget, type):
             widget = widget(attrs={'type': 'number', 'step': 'any'})

{"golden_diff": "diff --git a/saleor/core/weight.py b/saleor/core/weight.py\n--- a/saleor/core/weight.py\n+++ b/saleor/core/weight.py\n@@ -70,8 +70,8 @@\n             return value.value\n         return value\n \n-    def render(self, name, value, attrs=None):\n-        widget = super().render(name, value, attrs=attrs)\n+    def render(self, name, value, attrs=None, renderer=None):\n+        widget = super().render(name, value, attrs=attrs, renderer=renderer)\n         unit = get_default_weight_unit()\n         translated_unit = dict(WeightUnits.CHOICES)[unit]\n         return render_to_string(\n@@ -79,7 +79,7 @@\n             {'widget': widget, 'value': value, 'unit': translated_unit})\n \n \n-class WeightField(forms.DecimalField):\n+class WeightField(forms.FloatField):\n     def __init__(self, *args, widget=WeightInput, min_value=0, **kwargs):\n         if isinstance(widget, type):\n             widget = widget(attrs={'type': 'number', 'step': 'any'})\n", "issue": "Django 2.1 compatibility\nWe should switch our supported Django version to the following list:\r\n* Django 1.11 (current LTS)\r\n* Django 2.1 (latest stable)\r\n\r\nCurrent blockers:\r\n* [x] `graphene-django` depends on an old version of `django-filters` (https://github.com/graphql-python/graphene-django/pull/492)\r\n* [x] WeightInput passes floats to its base class which is a DecimalField\r\n* [x] Some form widgets pass `renderer` to functions that don't expect it\n", "before_files": [{"content": "\"\"\"In Saleor we are using 'weight' instead of a 'mass'.\n\nFor those of us who are earth-bound, weight is what we usually experience.\nMass is a theoretical construct.\nUnless we are dealing with inertia and momentum, we are encountering\nthe attractive force between ourselves and the earth,\nthe isolated effects of mass alone being a little more esoteric.\n\nSo even though mass is more fundamental, most people think\nin terms of weight.\n\nIn the end, it does not really matter unless you travel between\ndifferent planets.\n\"\"\"\nfrom decimal import Decimal\nfrom enum import Enum\n\nfrom django import forms\nfrom django.contrib.sites.models import Site\nfrom django.core.validators import MinValueValidator\nfrom django.template.loader import render_to_string\nfrom django.utils.translation import pgettext_lazy\nfrom measurement.measures import Weight\n\n\nclass WeightUnits:\n    KILOGRAM = 'kg'\n    POUND = 'lb'\n    OUNCE = 'oz'\n    GRAM = 'g'\n\n    CHOICES = [\n        (KILOGRAM, pgettext_lazy('Kilogram weight unit symbol', 'kg')),\n        (POUND, pgettext_lazy('Pound weight unit symbol', 'lb')),\n        (OUNCE, pgettext_lazy('Ounce weight unit symbol', 'oz')),\n        (GRAM, pgettext_lazy('Gram weight unit symbol', 'g'))]\n\n\nWeightUnitsEnum = Enum(\n    'WeightUnitsEnum',\n    {unit: unit for unit in WeightUnits.CHOICES})\n\n\ndef zero_weight():\n    \"\"\"Function used as a model's default.\"\"\"\n    return Weight(kg=0)\n\n\ndef convert_weight(weight, unit):\n    # Weight amount from the Weight instance can be retrived in serveral units\n    # via its properties. eg. Weight(lb=10).kg\n    converted_weight = getattr(weight, unit)\n    return Weight(**{unit: converted_weight})\n\n\ndef get_default_weight_unit():\n    site = Site.objects.get_current()\n    return site.settings.default_weight_unit\n\n\nclass WeightInput(forms.TextInput):\n    template = 'dashboard/shipping/weight_widget.html'\n    input_type = 'number'\n\n    def format_value(self, value):\n        if isinstance(value, Weight):\n            unit = get_default_weight_unit()\n            if value.unit != unit:\n                value = convert_weight(value, unit)\n            return value.value\n        return value\n\n    def render(self, name, value, attrs=None):\n        widget = super().render(name, value, attrs=attrs)\n        unit = get_default_weight_unit()\n        translated_unit = dict(WeightUnits.CHOICES)[unit]\n        return render_to_string(\n            self.template,\n            {'widget': widget, 'value': value, 'unit': translated_unit})\n\n\nclass WeightField(forms.DecimalField):\n    def __init__(self, *args, widget=WeightInput, min_value=0, **kwargs):\n        if isinstance(widget, type):\n            widget = widget(attrs={'type': 'number', 'step': 'any'})\n        super().__init__(*args, widget=widget, **kwargs)\n        if min_value is not None:\n            self.validators.append(MinValueValidator(min_value))\n\n    def to_python(self, value):\n        value = super().to_python(value)\n        if value is None:\n            return value\n        unit = get_default_weight_unit()\n        return Weight(**{unit: value})\n\n    def validate(self, weight):\n        if weight is None or weight in self.empty_values:\n            super().validate(weight)\n        else:\n            unit = get_default_weight_unit()\n            if not isinstance(weight, Weight):\n                raise Exception(\n                    '%r is not a valid weight.' % (weight,))\n            if weight.unit != unit:\n                raise forms.ValidationError(\n                    'Invalid unit: %r (expected %r).' % (\n                        weight.unit, unit))\n            super().validate(weight.value)\n\n    def clean(self, value):\n        value = value_to_be_validated = self.to_python(value)\n        self.validate(value_to_be_validated)\n        if isinstance(value, Weight):\n            value_to_be_validated = Decimal(value.value)\n        # default decimal validators can be used for Weight's value only\n        self.run_validators(value_to_be_validated)\n        return value\n", "path": "saleor/core/weight.py"}], "after_files": [{"content": "\"\"\"In Saleor we are using 'weight' instead of a 'mass'.\n\nFor those of us who are earth-bound, weight is what we usually experience.\nMass is a theoretical construct.\nUnless we are dealing with inertia and momentum, we are encountering\nthe attractive force between ourselves and the earth,\nthe isolated effects of mass alone being a little more esoteric.\n\nSo even though mass is more fundamental, most people think\nin terms of weight.\n\nIn the end, it does not really matter unless you travel between\ndifferent planets.\n\"\"\"\nfrom decimal import Decimal\nfrom enum import Enum\n\nfrom django import forms\nfrom django.contrib.sites.models import Site\nfrom django.core.validators import MinValueValidator\nfrom django.template.loader import render_to_string\nfrom django.utils.translation import pgettext_lazy\nfrom measurement.measures import Weight\n\n\nclass WeightUnits:\n    KILOGRAM = 'kg'\n    POUND = 'lb'\n    OUNCE = 'oz'\n    GRAM = 'g'\n\n    CHOICES = [\n        (KILOGRAM, pgettext_lazy('Kilogram weight unit symbol', 'kg')),\n        (POUND, pgettext_lazy('Pound weight unit symbol', 'lb')),\n        (OUNCE, pgettext_lazy('Ounce weight unit symbol', 'oz')),\n        (GRAM, pgettext_lazy('Gram weight unit symbol', 'g'))]\n\n\nWeightUnitsEnum = Enum(\n    'WeightUnitsEnum',\n    {unit: unit for unit in WeightUnits.CHOICES})\n\n\ndef zero_weight():\n    \"\"\"Function used as a model's default.\"\"\"\n    return Weight(kg=0)\n\n\ndef convert_weight(weight, unit):\n    # Weight amount from the Weight instance can be retrived in serveral units\n    # via its properties. eg. Weight(lb=10).kg\n    converted_weight = getattr(weight, unit)\n    return Weight(**{unit: converted_weight})\n\n\ndef get_default_weight_unit():\n    site = Site.objects.get_current()\n    return site.settings.default_weight_unit\n\n\nclass WeightInput(forms.TextInput):\n    template = 'dashboard/shipping/weight_widget.html'\n    input_type = 'number'\n\n    def format_value(self, value):\n        if isinstance(value, Weight):\n            unit = get_default_weight_unit()\n            if value.unit != unit:\n                value = convert_weight(value, unit)\n            return value.value\n        return value\n\n    def render(self, name, value, attrs=None, renderer=None):\n        widget = super().render(name, value, attrs=attrs, renderer=renderer)\n        unit = get_default_weight_unit()\n        translated_unit = dict(WeightUnits.CHOICES)[unit]\n        return render_to_string(\n            self.template,\n            {'widget': widget, 'value': value, 'unit': translated_unit})\n\n\nclass WeightField(forms.FloatField):\n    def __init__(self, *args, widget=WeightInput, min_value=0, **kwargs):\n        if isinstance(widget, type):\n            widget = widget(attrs={'type': 'number', 'step': 'any'})\n        super().__init__(*args, widget=widget, **kwargs)\n        if min_value is not None:\n            self.validators.append(MinValueValidator(min_value))\n\n    def to_python(self, value):\n        value = super().to_python(value)\n        if value is None:\n            return value\n        unit = get_default_weight_unit()\n        return Weight(**{unit: value})\n\n    def validate(self, weight):\n        if weight is None or weight in self.empty_values:\n            super().validate(weight)\n        else:\n            unit = get_default_weight_unit()\n            if not isinstance(weight, Weight):\n                raise Exception(\n                    '%r is not a valid weight.' % (weight,))\n            if weight.unit != unit:\n                raise forms.ValidationError(\n                    'Invalid unit: %r (expected %r).' % (\n                        weight.unit, unit))\n            super().validate(weight.value)\n\n    def clean(self, value):\n        value = value_to_be_validated = self.to_python(value)\n        self.validate(value_to_be_validated)\n        if isinstance(value, Weight):\n            value_to_be_validated = Decimal(value.value)\n        # default decimal validators can be used for Weight's value only\n        self.run_validators(value_to_be_validated)\n        return value\n", "path": "saleor/core/weight.py"}]}