#35233: Push templates checks down to backend engine classes
------------------------------------------------+------------------------
               Reporter:  Adam Johnson          |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Core (System checks)  |        Version:  dev
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 Currently, the three system checks for template settings are individual
 functions in
 [https://github.com/django/django/blob/main/django/core/checks/templates.py
 django.core.checks.templates]. This structure leads to some issues:

 1. The checks are specific to DTL (Django Template Language), but get run
 for all backends. DTL-specific code gets loaded and run even when not
 using it, notably the fairly slow `get_template_tag_modules()`.
 2. `check_for_template_tags_with_the_same_name` is inaccurate because it
 combines `libraries` from all template backends, so might report an issue
 when none exists.
 3. The checks are still run when no template backend is configured
 (`settings.TEMPLATES = []`).

 I propose the checks be restructured to live within the engine classes in
 `django.template.backends`, adopting the same pattern used for model and
 field checks, admin checks, etc.

 In practice, this would mean adding a dummy `BaseEngine.check()` method,
 then moving the existing checks into methods called by an overridden
 `DjangoTemplates.check()`. A single function left in
 `django.core.checks.templates` would loop over
 `django.template.engines.all()` to combine results from backends’
 `check()` methods.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35233>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018dbe7fa9e9-acafe270-0bb4-48e0-81bf-97f525d31e3e-000000%40eu-central-1.amazonses.com.

Reply via email to