Django how to handle # in variable name.

Posted by Jack on Stack Overflow See other posts from Stack Overflow or by Jack
Published on 2010-05-30T15:40:50Z Indexed on 2010/05/30 17:12 UTC
Read the original article Hit count: 275

Filed under:
|

I've got a dictionary in python which is assigned as a template variable. One of the keys is named "#text" but when i try to access it using {{ artist.image.3."#text"}} I get an error which is

  File "/home/jack/Desktop/test/appengine/lib/django/django/template/__init__.py", line 558, in __init__
    raise TemplateSyntaxError, "Could not parse the remainder: %s" % token[upto:]
TemplateSyntaxError: Could not parse the remainder: "#text"

So how can I use this in the template? I've tried putting quotes around it but to no avail. I'd like to not modify the dictionary if possible, but if its easy enough to do then I guess its okay.

Thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about django-templates