[Python] Django CSRF failing with .env file for Docker

Discussão em 'Python' iniciado por Stack, Outubro 4, 2024.

  1. Stack

    Stack Membro Participativo

    Hi I'm using Docker to build a Django web application via Docker-Compose and it uses the .env.dev file for the environmental variables.

    The problem is the CSRF_TRUSTED_ORIGINS variables :

    • If i put variables inside the settings.py => Ok
    • If i put variables inside the env.dev => KO ( AttributeError: 'NoneType' object has no attribute 'split')

    settings.py

    # CSRF_TRUSTED_ORIGINS=["https://www.site1.fr", "http://www.site1.fr"]
    CSRF_TRUSTED_ORIGINS= os.environ.get("DJANGO_CSRF").split(" ")


    env.dev

    DJANGO_CSRF=https://www.site1.fr http://www.site1.fr

    Continue reading...

Compartilhe esta Página