From 061a2e852d8d6090eb108d1cba5da8ca269464db Mon Sep 17 00:00:00 2001 From: sonny Date: Tue, 16 Jun 2020 09:04:34 +0200 Subject: [PATCH] 0.2.3.3 - Fix admin --- src/newsreader/conf/base.py | 5 +++-- src/newsreader/conf/dev.py | 16 ---------------- src/newsreader/utils/form.py | 16 ---------------- 3 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 src/newsreader/utils/form.py diff --git a/src/newsreader/conf/base.py b/src/newsreader/conf/base.py index 5d46230..c911462 100644 --- a/src/newsreader/conf/base.py +++ b/src/newsreader/conf/base.py @@ -22,6 +22,7 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "django.forms", # third party apps "rest_framework", "drf_yasg", @@ -55,6 +56,8 @@ MIDDLEWARE = [ ROOT_URLCONF = "newsreader.urls" +FORM_RENDERER = "django.forms.renderers.TemplatesSetting" + TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", @@ -71,8 +74,6 @@ TEMPLATES = [ } ] -FORM_RENDERER = "newsreader.utils.form.FormRenderer" - WSGI_APPLICATION = "newsreader.wsgi.application" # Database diff --git a/src/newsreader/conf/dev.py b/src/newsreader/conf/dev.py index b81a9fa..8186db7 100644 --- a/src/newsreader/conf/dev.py +++ b/src/newsreader/conf/dev.py @@ -9,22 +9,6 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" INSTALLED_APPS += ["debug_toolbar", "django_extensions"] -TEMPLATES = [ - { - "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [os.path.join(DJANGO_PROJECT_DIR, "templates")], - "APP_DIRS": True, - "OPTIONS": { - "context_processors": [ - "django.template.context_processors.debug", - "django.template.context_processors.request", - "django.contrib.auth.context_processors.auth", - "django.contrib.messages.context_processors.messages", - ] - }, - } -] - # Third party settings AXES_FAILURE_LIMIT = 50 AXES_COOLOFF_TIME = None diff --git a/src/newsreader/utils/form.py b/src/newsreader/utils/form.py deleted file mode 100644 index dc619bf..0000000 --- a/src/newsreader/utils/form.py +++ /dev/null @@ -1,16 +0,0 @@ -from django.forms.renderers import DjangoTemplates -from django.template.exceptions import TemplateDoesNotExist -from django.template.loader import get_template - - -class FormRenderer(DjangoTemplates): - """ - Prioritizes templates from TEMPLATES setting and fall's back to django's - default FormRenderer behaviour - """ - - def get_template(self, template_name): - try: - return get_template(template_name) - except TemplateDoesNotExist: - return super().get_template(template_name)