Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19479 closed Bug (duplicate)

The {% include with...%} template tag does not accept boolean as value

Reported by: italo.maia@… Owned by: nobody
Component: Template system Version: 1.4
Severity: Normal Keywords:
Cc: charette.s@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Folks, the following doesn't work:

{% include "some_template.html" with param=True %}

param is not available in some_template.html If I use a number in param, it works.

Change History (1)

comment:1 by Simon Charette, 12 years ago

Cc: charette.s@… added
Resolution: duplicate
Status: newclosed

Couldn't reproduce against master:

simon@imac:~$ mktmpenv 
New python executable in d58d6e9f-7c22-429a-9052-e34bf4642c03/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /home/simon/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/simon/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/simon/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/bin/preactivate
virtualenvwrapper.user_scripts creating /home/simon/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/bin/postactivate
virtualenvwrapper.user_scripts creating /home/simon/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/bin/get_env_details
bash: cd: /home/simon/workspace/d58d6e9f-7c22-429a-9052-e34bf4642c03: Aucun fichier ou dossier de ce type
This is a temporary environment. It will be deleted when you run 'deactivate'.
(d58d6e9f-7c22-429a-9052-e34bf4642c03)simon@imac:~/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03$ pip install django==1.5
Downloading/unpacking django==1.5
  Could not find a version that satisfies the requirement django==1.5 (from versions: )
No distributions matching the version for django==1.5
Storing complete log in /home/simon/.pip/pip.log
(d58d6e9f-7c22-429a-9052-e34bf4642c03)simon@imac:~/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03$ pip install https://github.com/django/django/archive/master.zip
Downloading/unpacking https://github.com/django/django/archive/master.zip
  Downloading master.zip (11.5Mb): 11.5Mb downloaded
  Running setup.py egg_info for package from https://github.com/django/django/archive/master.zip
    
    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
Installing collected packages: Django
  Running setup.py install for Django
    changing mode of build/scripts-2.7/django-admin.py from 664 to 775
    
    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
    changing mode of /home/simon/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/bin/django-admin.py to 775
Successfully installed Django
Cleaning up...
(d58d6e9f-7c22-429a-9052-e34bf4642c03)simon@imac:~/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03$ django-admin.py startproject ticket_19479
(d58d6e9f-7c22-429a-9052-e34bf4642c03)simon@imac:~/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03$ cd ticket_19479/
(d58d6e9f-7c22-429a-9052-e34bf4642c03)simon@imac:~/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/ticket_19479$ mkdir templates
(d58d6e9f-7c22-429a-9052-e34bf4642c03)simon@imac:~/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/ticket_19479$ echo "{% if param %}works{% endif %}" > templates/included
(d58d6e9f-7c22-429a-9052-e34bf4642c03)simon@imac:~/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/ticket_19479$ echo "{% include \"included\" with param=True %}" > templates/includer
(d58d6e9f-7c22-429a-9052-e34bf4642c03)simon@imac:~/.virtualenvs/d58d6e9f-7c22-429a-9052-e34bf4642c03/ticket_19479$ python
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.conf import settings
>>> import os
>>> settings.configure(DEBUG=True, TEMPLATE_DEBUG=True, TEMPLATE_DIRS=(os.path.join(os.getcwd(), 'templates'),))
>>> from django.template.loader import render_to_string
>>> render_to_string('includer')
u'works\n\n'

Prior to django 1.5 the True, False and None literals weren't resolving to their Python equivalent in the template system.

That's the reason why it doesn't work for you here. For more details see #17229.

Closing as duplicate.

Version 0, edited 12 years ago by Simon Charette (next)
Note: See TracTickets for help on using tickets.
Back to Top