Repository: digitalfabrik/integreat-cms

Issue:
Upgrade Django to version 3
### Motivation
<!-- A clear and concise description of what the motivation for the new feature is, and what problem it is solving. -->
In April 2021, The most recent Django version 3 will receive long-term-support with 3.2 LTS until 2024 (see [supported versions](https://www.djangoproject.com/download/#supported-versions)). Since our used version 2.2 LTS is "only" supported until April 2022, we have to upgrade until then anyway. Since major version changes come with the risk of breaking changes, I think it makes sense to upgrade before our first stable release and the migration of WordPress to Django.

### Proposed Solution
<!-- A clear and concise description of the feature you would like to add, and how it solves the motivating problem. -->
Follow the guide [Upgrading Django to a newer version](https://docs.djangoproject.com/en/3.1/howto/upgrade-version/)

### Alternatives
<!-- A clear and concise description of any alternative solutions or features you've considered, and why you're proposed solution is better. -->
Wait another year before upgrading

### Additional Context
<!-- Add any other information or screenshots about the feature request here. -->




Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -31,7 +31,7 @@
     ],
     install_requires=[
         "cffi",
-        "Django~=2.2.13",
+        "Django==3.1.7",
         "django-cors-headers",
         "django-filer",
         "django-mptt",
diff --git a/sphinx/conf.py b/sphinx/conf.py
--- a/sphinx/conf.py
+++ b/sphinx/conf.py
@@ -12,6 +12,8 @@
 import inspect
 import importlib
 
+from django import VERSION as django_version
+
 from backend.settings import VERSION
 
 # Append project source directory to path environment variable
@@ -20,6 +22,8 @@
 sys.path.append(os.path.abspath("./"))
 #: The path to the django settings module (see :doc:`sphinxcontrib-django2:readme`)
 django_settings = "backend.sphinx_settings"
+#: The "major.minor" version of Django
+django_doc_version = f"{django_version[0]}.{django_version[1]}"
 
 # -- Project information -----------------------------------------------------
 
@@ -57,7 +61,10 @@
 ]
 #: Enable cross-references to other documentations
 intersphinx_mapping = {
-    "python": ("https://docs.python.org/3.7/", None),
+    "python": (
+        f"https://docs.python.org/{sys.version_info.major}.{sys.version_info.minor}/",
+        None,
+    ),
     "pipenv": ("https://pipenv.pypa.io/en/latest/", None),
     "requests": ("https://requests.readthedocs.io/en/master/", None),
     "sphinx": ("https://www.sphinx-doc.org/en/master/", None),
@@ -74,8 +81,8 @@
         None,
     ),
     "django": (
-        "https://docs.djangoproject.com/en/2.2/",
-        "https://docs.djangoproject.com/en/2.2/_objects/",
+        f"https://docs.djangoproject.com/en/{django_doc_version}/",
+        f"https://docs.djangoproject.com/en/{django_doc_version}/_objects/",
     ),
     "django-compressor": ("https://django-compressor.readthedocs.io/en/stable/", None),
     "django-filer": ("https://django-filer.readthedocs.io/en/latest/", None),
diff --git a/src/cms/models/offers/offer_template.py b/src/cms/models/offers/offer_template.py
--- a/src/cms/models/offers/offer_template.py
+++ b/src/cms/models/offers/offer_template.py
@@ -1,5 +1,4 @@
 from django.db import models
-from django.contrib.postgres.fields import JSONField
 from django.utils import timezone
 from django.utils.translation import ugettext_lazy as _
 
@@ -32,7 +31,7 @@ class OfferTemplate(models.Model):
         verbose_name=_("URL"),
         help_text=_("This will be an external API endpoint in most cases."),
     )
-    post_data = JSONField(
+    post_data = models.JSONField(
         max_length=250,
         default=dict,
         blank=True,


Test patch: