Drop support for end of life Django settings in demo project

This commit is contained in:
johnthagen 2021-01-21 11:28:40 -05:00
parent 9f42e65986
commit 6338f61767
2 changed files with 33 additions and 43 deletions

4
.gitignore vendored
View file

@ -23,6 +23,10 @@ coverage.xml
/build/ /build/
/dist/ /dist/
# Virtual environments (created by user).
/venv/
# Editors' temporary buffers. # Editors' temporary buffers.
.*.swp .*.swp
*~ *~
.idea

View file

@ -1,8 +1,7 @@
"""Django settings for django-downloadview demo project.""" """Django settings for django-downloadview demo project."""
from distutils.version import StrictVersion
import os import os
from django.utils.version import get_version
# Configure some relative directories. # Configure some relative directories.
demoproject_dir = os.path.dirname(os.path.abspath(__file__)) demoproject_dir = os.path.dirname(os.path.abspath(__file__))
@ -61,24 +60,14 @@ INSTALLED_APPS = (
# BEGIN middlewares # BEGIN middlewares
if StrictVersion(get_version()) >= StrictVersion("1.10"): MIDDLEWARE = [
MIDDLEWARE = [ "django.middleware.common.CommonMiddleware",
"django.middleware.common.CommonMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
"django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django_downloadview.SmartDownloadMiddleware",
"django_downloadview.SmartDownloadMiddleware", ]
]
else:
MIDDLEWARE_CLASSES = [
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django_downloadview.SmartDownloadMiddleware",
]
# END middlewares # END middlewares
@ -133,27 +122,24 @@ NOSE_ARGS = [
"--with-doctest", "--with-doctest",
] ]
if StrictVersion(get_version()) >= StrictVersion("1.8"):
TEMPLATES = [ TEMPLATES = [
{ {
"BACKEND": "django.template.backends.django.DjangoTemplates", "BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(os.path.dirname(__file__), "templates")], "DIRS": [os.path.join(os.path.dirname(__file__), "templates")],
"OPTIONS": { "OPTIONS": {
"debug": DEBUG, "debug": DEBUG,
"context_processors": [ "context_processors": [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this # Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
# list if you haven't customized them: # list if you haven't customized them:
"django.contrib.auth.context_processors.auth", "django.contrib.auth.context_processors.auth",
"django.template.context_processors.debug", "django.template.context_processors.debug",
"django.template.context_processors.i18n", "django.template.context_processors.i18n",
"django.template.context_processors.media", "django.template.context_processors.media",
"django.template.context_processors.static", "django.template.context_processors.static",
"django.template.context_processors.tz", "django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages", "django.contrib.messages.context_processors.messages",
], ],
},
}, },
] },
else: ]
TEMPLATE_DEBUG = DEBUG
TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), "templates"),)