carltongibson / django-template-partials

Reusable named inline partials for the Django Template Language.
MIT License
387 stars 15 forks source link

Configuration in doc not correct? #17

Closed mjmare closed 11 months ago

mjmare commented 11 months ago

I have copied the required setup from the docs page, and added 1 template folder. However I'm getting a this warning:

?: (debug_toolbar.W006) At least one DjangoTemplates TEMPLATES configuration needs to use django.template.loaders.app_directories.Loader or have APP_DIRS set to True.
        HINT: Include django.template.loaders.app_directories.Loader in ["OPTIONS"]["loaders"]. Alternatively use APP_DIRS=True for at least one django.template.backends.django.DjangoTemplates backend configuration.

Nevertheless the config seems fine to me. The config:

# Install app and configure loader.
default_loaders = [
    "django.template.loaders.filesystem.Loader",
    "django.template.loaders.app_directories.Loader",
]
cached_loaders = [("django.template.loaders.cached.Loader", default_loaders)]
partial_loaders = [("template_partials.loader.Loader", cached_loaders)]
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [
            os.path.join(PROJECT_DIR, "templates"),
        ],
        # Comment this out when manually defining loaders.
        # "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",
            ],
            "debug": True,
            # TODO: Add wrap_loaded function to the called from an AppConfig.ready().
            "loaders": partial_loaders,
        },
    },
]
carltongibson commented 11 months ago

I think that error was resolved in a recent version of DDT.

mjmare commented 11 months ago

Ah I see. I was using 4.1.0. The reported bug (by you ;-) seems to be fixed in 4.2.

Do you think the configuration can be simplified in the future?

carltongibson commented 11 months ago

Yes, see #11. I just need a moment to be able to review and pull it in.