-
-
Save AnSavvides/d6725db951f75788e8eb to your computer and use it in GitHub Desktop.
Django Templating: Variable named 'new' behaves unexpectedly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
{% if not_new %} | |
{{not_new}} | |
{% endif %} | |
<p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
{% if new %} | |
{{new}} | |
{% endif %} | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.template import loader, Context | |
# This one works as expected | |
template = loader.get_template('some_template.html') | |
context = Context({}) | |
body = template.render(context) | |
# body now is: <p></p> | |
# This one does not work as expected. | |
buggy_template = loader.get_template('some_buggy_template.html') | |
buggy_context = Context({}) | |
buggy_body = template.render(buggy_context) | |
# buggy_body now is: <p>[{}]</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment