Google App Engine: template not working when displaying html form -
in python code have
the_button = '''<form action="/edit" method="get" > <input type="submit" name="edit" value="edit" /> </form>''' template_values = { 'the_button':the_button } path = os.path.join(os.path.dirname(__file__), 'the.html') self.response.out.write(template.render(path, template_values))
the problem when see in page show button non-clickable, when view page source of html doesn't show code.
what problem?
thanks!
webapp escaping raw html.
try add safe
filter this:
{{ the_button|safe }}
from django documentation:
safe
marks string not requiring further html escaping prior output.
when autoescaping off, filter has no effect.
edit:
unluckily google app engine out of box runs django 0.96 not have feature.
have 2 options:
- install more recent version of django (django-nonrel)
- ask why need pass raw risky html snippet controller view.
move button view instead, allowing controller show or not using simpleshow_button
boolean variable.
in controller:
show_button = true template_values = { 'show_button':show_button } path = os.path.join(os.path.dirname(__file__), 'the.html') self.response.out.write(template.render(path, template_values))
in the.html
{%if show_button %} <form action="/edit" method="get" > <input type="submit" name="edit" value="edit" /> </form> {% endif %}
Comments
Post a Comment