--
Ticket URL: <https://code.djangoproject.com/ticket/16147>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* has_patch: 0 => 1
* stage: Unreviewed => Design decision needed
* needs_tests: => 1
* needs_better_patch: => 1
Comment:
Replying to:
> Why does Django try to execute the {% include %} when it contains a hard
coded string at compile time at all?
[[BR]]
This feature (or bug) has "always" existed. I couldn't find an explanation
in the code or the commit messages.
- It was added at r1349, which introduced the `{% include %}` tag.
- It was moved from django/core/template/loader.py to
django/template/loader_tags.py at r1443, and not changed since then.
Both changes were committed by Adrian in Nov '05.
Hopefully the discussion on the mailing list will help sort it out:
https://groups.google.com/group/django-
developers/browse_thread/thread/f1c2e3664c8aace2
----
Technically, the problem is the implementation of
`django.template.loader_tags.ConstantIncludeNode`: the template resolution
with `get_template` should be moved from `__init__` to `render`.
I'm attaching a patch that fixes it with the minimum amount of changes,
just to show the idea. However:
- after the patch, `ConstantIncludeNode` and `IncludeNode` are very
similar; some refactoring would be useful,
- it breaks the test suite.
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:1>
Comment (by aaugustin):
The original reporter found the explanation for this optimization and
posted it on IRC:
https://code.djangoproject.com/ticket/598#comment:2
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:2>
* needs_better_patch: 1 => 0
* version: 1.3 => 1.4-alpha-1
* needs_tests: 1 => 0
* ui_ux: => 0
Comment:
I added an updated patch with tests.
It's a comprehensive patch that replaces BaseIncludeNode,
ConstantIncludeNode, and IncludeNode with a single implementation.
I also rewrote the tests in a form I find readable, but kept the existing
tests in place so a reviewer can verify backwards compatibility. Besides
that, the old tests are redundant.
In addition to this ticket, this patch addresses #12064 and #3544.
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:4>
* cc: prestontimmons@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:5>
Comment (by aaugustin):
Shortening title because it degrades the layout of Trac :)
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:6>
* cc: anton@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:7>
* owner: nobody => aaugustin
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:8>
Comment (by prestontimmons):
Updated the patch and added a pull request for review.
https://github.com/django/django/pull/920
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:9>
* stage: Design decision needed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:10>
* cc: FunkyBob (added)
Comment:
I've made a PR for a simpler patch for this:
https://github.com/django/django/pull/1528
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:11>
* version: 1.4-alpha-1 => master
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:12>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"e2f06226ea4a38377cdb69f2f5768e4e00c2d88e"]:
{{{
#!CommitTicketReference repository=""
revision="e2f06226ea4a38377cdb69f2f5768e4e00c2d88e"
Improved {% include %} implementation
Merged BaseIncludeNode, ConstantIncludeNode and Include node.
This avoids raising TemplateDoesNotExist at parsing time, allows recursion
when passing a literal template name, and should make TEMPLATE_DEBUG
behavior
consistant.
Thanks loic84 for help with the tests.
Fixed #3544, fixed #12064, fixed #16147
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/16147#comment:13>