Repository: alsoicode/django-maintenancemode-2 (language: python)

Issue:
missing migration
- Alter field description on ignoredurl
- Alter field is_being_performed on maintenance

Please let Django generate the missing migration und publish it. :)


Discussion / hints:

Fix patch:
diff --git a/maintenancemode/migrations/0003_auto_20180227_0331.py b/maintenancemode/migrations/0003_auto_20180227_0331.py
new file mode 100644
index 0000000..1ee4ecf
--- /dev/null
+++ b/maintenancemode/migrations/0003_auto_20180227_0331.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.10 on 2018-02-27 03:31
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('maintenancemode', '0002_auto_20170920_1455'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='ignoredurl',
+            name='description',
+            field=models.CharField(help_text='What this URL pattern covers.', max_length=75),
+        ),
+        migrations.AlterField(
+            model_name='maintenance',
+            name='is_being_performed',
+            field=models.BooleanField(default=False, verbose_name='In Maintenance Mode'),
+        ),
+    ]


Test patch:
diff --git a/testproject/testproject/settings.py b/testproject/testproject/settings.py
index a4e2e4e..bf1c65d 100644
--- a/testproject/testproject/settings.py
+++ b/testproject/testproject/settings.py
@@ -51,21 +51,33 @@
     'maintenancemode',
 )
 
-MIDDLEWARE_CLASSES = (
-    'django.contrib.sessions.middleware.SessionMiddleware',
-    'django.middleware.common.CommonMiddleware',
-    'django.middleware.csrf.CsrfViewMiddleware',
-    'django.contrib.auth.middleware.AuthenticationMiddleware',
-    'django.contrib.messages.middleware.MessageMiddleware',
-    'django.middleware.clickjacking.XFrameOptionsMiddleware',
-)
+
+if DJANGO_MAJOR_VERSION == 1 and DJANGO_MAJOR_VERSION < 10:
+    MIDDLEWARE_CLASSES = (
+        'django.contrib.sessions.middleware.SessionMiddleware',
+        'django.middleware.common.CommonMiddleware',
+        'django.middleware.csrf.CsrfViewMiddleware',
+        'django.contrib.auth.middleware.AuthenticationMiddleware',
+        'django.contrib.messages.middleware.MessageMiddleware',
+        'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    )
+else:
+    MIDDLEWARE = [
+        'django.middleware.security.SecurityMiddleware',
+        'django.contrib.sessions.middleware.SessionMiddleware',
+        'django.middleware.common.CommonMiddleware',
+        'django.middleware.csrf.CsrfViewMiddleware',
+        'django.contrib.auth.middleware.AuthenticationMiddleware',
+        'django.contrib.messages.middleware.MessageMiddleware',
+        'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    ]
 
 TEMPLATE_DIRECTORY = os.path.join(BASE_DIR, 'templates')
 
 if DJANGO_MAJOR_VERSION >= 1:
 
     # Templates
-    if DJANGO_MINOR_VERSION < 8:
+    if DJANGO_MINOR_VERSION < 8 and DJANGO_MAJOR_VERSION == 1:
         TEMPLATE_DIRS = (
             TEMPLATE_DIRECTORY,
         )
@@ -101,17 +113,19 @@
         ]
 
     # Sessions
-    if DJANGO_MINOR_VERSION == 7:
+    if DJANGO_MAJOR_VERSION == 1 and DJANGO_MINOR_VERSION == 7:
         MIDDLEWARE_CLASSES += (
             'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
         )
-    else:
+    elif DJANGO_MAJOR_VERSION == 1:
         MIDDLEWARE_CLASSES += (
             'django.middleware.security.SecurityMiddleware',
         )
-
-MIDDLEWARE_CLASSES += ('maintenancemode.middleware.MaintenanceModeMiddleware',)
-
+    
+if DJANGO_MAJOR_VERSION == 1 and DJANGO_MAJOR_VERSION < 10:
+    MIDDLEWARE_CLASSES += ('maintenancemode.middleware.MaintenanceModeMiddleware',)
+else:
+    MIDDLEWARE += ['maintenancemode.middleware.MaintenanceModeMiddleware']
 
 ROOT_URLCONF = 'testproject.urls'
 
diff --git a/testproject/testproject/urls.py b/testproject/testproject/urls.py
index 546c5ea..03cb73b 100644
--- a/testproject/testproject/urls.py
+++ b/testproject/testproject/urls.py
@@ -13,10 +13,21 @@
     1. Add an import:  from blog import urls as blog_urls
     2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
 """
-from django.conf.urls import include, url
+from distutils.version import StrictVersion
+from django.conf.urls import include
 from django.contrib import admin
+from maintenancemode.utils.settings import DJANGO_VERSION
 
-urlpatterns = [
-    url(r'^admin/', include(admin.site.urls)),
-    url(r'^', include('app.urls', namespace='app')),
-]
+if DJANGO_VERSION >= StrictVersion('2.0'): 
+    from django.urls import path
+    urlpatterns = [
+        path(r'admin/', admin.site.urls),
+        path(r'', include('app.urls')),
+    ]
+    
+else:
+    from django.conf.urls import url
+    urlpatterns = [
+        url(r'^admin/', include(admin.site.urls)),
+        url(r'^', include('app.urls', namespace='app')),
+    ]