Finish Form Rewrite

This commit is contained in:
2026-05-08 09:43:19 +02:00
parent 551057b067
commit a50cadc873
18 changed files with 163 additions and 167 deletions
-11
View File
@@ -1,11 +0,0 @@
from jinja2 import Environment
from django.urls import reverse
from django.templatetags.static import static
def environment(**options):
env = Environment(**options)
env.globals.update({
'static': static,
'url': reverse,
})
return env
+10 -9
View File
@@ -14,6 +14,7 @@ import logging
import os, sys
from pathlib import Path
DEV_ENV = (sys.argv[1] == 'runserver')
RUNNING_TESTS = any(arg in {'test', 'pytest'} for arg in sys.argv) or 'PYTEST_CURRENT_TEST' in os.environ
@@ -101,6 +102,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.forms',
'compressor',
]
@@ -136,14 +138,6 @@ TEMPLATES = [
],
},
},
{
'BACKEND': 'django.template.backends.jinja2.Jinja2',
'DIRS': [BASE_DIR / 'templates/jinja2'],
'APP_DIRS': True,
'OPTIONS': {
'environment': 'proyecto.jinja2.environment',
},
}
]
WSGI_APPLICATION = 'proyecto.wsgi.application'
@@ -429,4 +423,11 @@ CELERY_RESULT_SERIALIZER = 'json'
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
USE_X_FORWARDED_HOST = True
SECURE_REFERER_POLICY = "strict-origin-when-cross-origin"
SECURE_REFERER_POLICY = "strict-origin-when-cross-origin"
from django.forms.renderers import TemplatesSetting
class CustomFormRenderer(TemplatesSetting):
form_template_name = "tienda/form_snippet.html"
FORM_RENDERER = "proyecto.settings.CustomFormRenderer"