Changes between Initial Version and Version 1 of Ticket #35493


Ignore:
Timestamp:
Jun 4, 2024, 1:45:51 PM (4 months ago)
Author:
Gabriel Nick Pivovarov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35493 – Description

    initial v1  
    2222However, replacing the directory `./ul.html` with the equivalent `app/ul.html` makes the error go away (assuming that the project's `settings.py` specifies `APP_DIRS = True` and the views and URLs are configured correctly). The actual paths are translated identically in both cases, and the behavior of the `include` tag should not depend simply on whether or not the path string uses `./` or `../` (or if it should, this is not documented in the Django documentation). Therefore, it seems that this is a bug. The expected behavior is that an error is only raised when recursively using the `extends` template, not when recursively using the `include` template.
    2323
    24 Contrapositively, it appears that recursively extending a template using the `extends` tag with a path that does ''not'' contain `./` or `../` raises a `TemplateDoesNotExist` exception, which is semantically inaccurate since the template is referencing itself and therefore necessarily exists.
     24Contrapositively, it appears that recursively extending a template using the `extends` tag with a path that does ''not'' contain `./` or `../` raises a `TemplateDoesNotExist` exception.
    2525
    2626One possible fix is to modify the `django/template/loader_tags.py` file (https://github.com/django/django/blob/main/django/template/loader_tags.py) such that the error is raised when a template attempts to extend itself (not when a template attempts to include itself, which would otherwise be valid). The error handling logic in question starts on line 267 of that file within the `construct_relative_path` function; perhaps it should live somewhere in the `do_extends` function instead.
Back to Top