add csrf env settion

This commit is contained in:
Marc Koch 2025-04-25 17:33:11 +02:00
parent 1a2e88948a
commit 4a37e61265
Signed by: marc
GPG Key ID: 12406554CFB028B9
2 changed files with 5 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import markdown
import requests import requests
import shortuuid import shortuuid
from django.conf.global_settings import CSRF_TRUSTED_ORIGINS
from django.core.validators import URLValidator from django.core.validators import URLValidator
from django.db import models from django.db import models
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
@ -32,13 +33,15 @@ app = Django(
SECRET_KEY=DJANGO_SECRET_KEY, SECRET_KEY=DJANGO_SECRET_KEY,
TIME_ZONE=os.getenv("TIME_ZONE", "Europe/Berlin"), TIME_ZONE=os.getenv("TIME_ZONE", "Europe/Berlin"),
ALLOWED_HOSTS=["localhost"] + [host for host in ALLOWED_HOSTS=["localhost"] + [host for host in
os.getenv("ALLOWED_HOSTS", "").split(",")], os.getenv("DJANGO_ALLOWED_HOSTS", "").split(",")],
SQLITE_DATABASE=DATA_DIR / "db.sqlite3", SQLITE_DATABASE=DATA_DIR / "db.sqlite3",
DEBUG=DEBUG, DEBUG=DEBUG,
TEMPLATES_DIR=BASE_DIR / "templates", TEMPLATES_DIR=BASE_DIR / "templates",
STATICFILES_DIRS=[ STATICFILES_DIRS=[
BASE_DIR / "static", BASE_DIR / "static",
], ],
CSRF_TRUSTED_ORIGINS=[host for host in
os.getenv("DJANGO_ALLOWED_HOSTS", "").split(",")]
) )
# Import ninja after nanodjango has been initialised to avoid this error: # Import ninja after nanodjango has been initialised to avoid this error:

View File

@ -1 +1 @@
1.0.2 1.0.3