Skip to content

Side Note: Templates for django-cotton not getting picked up by the watcher #147

Closed
@Naude555

Description

@Naude555

Any HTML files in the templates/ directory under the project root are not being picked up. This is likely due to my custom setup, where the settings files are nested deeper in the directory structure than usual.

project_root/
    templates/
        base/
            not_pickedup.html
    config/
        django/
            base_settings.py
            dev.py
            prod.py
    accounts/
        templates/
            picked_up.html

To resolve this, add

BASE_DIR / "templates"

to your TEMPLATES setting to force it:

from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent.parent

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [
            BASE_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",
            ],
        },
    },
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions