Escaping of help_text in form fields

27 views
Skip to first unread message

not...@gmail.com

unread,
Nov 24, 2015, 9:34:18 AM11/24/15
to Django users
Hi !

Just stumbled upon this issue, with django 1.8.6:


from django import forms
from django.template import Template, Context
class A(forms.Form):

    f
= forms.CharField(help_text=u'bli "blo" >', label="bla <")
 
Template("{{form.as_p}}").render(Context({"form": A()}))


# returns:

u
'<p><label for="id_f">bla &lt;:</label> <input id="id_f" name="f" type="text" /> <span class="helptext">bli "blo" ></span></p>'



The label is escaped, but not the help_text.

  • Is that a bug ?
  • or should I mark all my help_text as unsafe ?
I did not find anything relevant in the doc or with google.

Regards,

NotSqrt

Tim Graham

unread,
Nov 24, 2015, 10:02:21 AM11/24/15
to Django users
It's expected behavior and mentioned in the model field help_text docs, but not form field help_text docs. I'll fix that.

https://docs.djangoproject.com/en/stable/ref/models/fields/#django.db.models.Field.help_text

not...@gmail.com

unread,
Nov 24, 2015, 10:04:18 AM11/24/15
to Django users
Perfect !
Thanks Tim !
Reply all
Reply to author
Forward
0 new messages