[Python] context_processors.py: files path?

Discussão em 'Python' iniciado por Stack, Fevereiro 11, 2025.

  1. Stack

    Stack Membro Participativo

    I have a context_processors.py files in one of my app that I declared in my settings.py and it works. but, as context_processors.py files's data are common to all the project, I would like to declare it at the root of my project but files is not recognized...

    current project's architecture

    - myproject
    - myproject
    - myapp
    - context_processors.py



    declared as follow in settings.py :

    TEMPLATES = [
    {
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [
    os.path.join(BASE_DIR,'registration/templates'),
    os.path.join(BASE_DIR,'templates'),
    ],
    'APP_DIRS': True,
    'OPTIONS': {
    'context_processors': [
    'myapp.context_processors.data_context_processor', <********************
    'django.template.context_processors.debug',
    'django.template.context_processors.request',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',
    ],
    },
    },
    ]


    expected project's architecture

    - myproject
    - myproject
    - context_processors.py
    - myapp



    How should I declare my context_processors.py files in settings.py? I try with os.path.join(BASE_DIR,'context_processors.data_context_processor') but it does not works...

    Continue reading...

Compartilhe esta Página