Opened 16 years ago

Last modified 6 years ago

#10449 new

Bug: HTML accents not escaped out when using newforms — at Initial Version

Reported by: tipan Owned by: nobody
Component: Internationalization Version: 1.0
Severity: Normal Keywords: accents, newforms
Cc: Guille López Triage Stage: Accepted
Has patch: no Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When passing a translated string to a select box using a Forms Select widget, the output string still contains accent HTML entity codes.

For example: "Problemas para el Inicio de Sesión o relacionados con la Cuenta

My code is set up as follows:

Models.py
from django.utils import translation
from django.utils.translation import ugettext_lazy as _

SUBJECT = (

(10, _('Log-in or Account related problems')),
(20, _('General enquiry')),
(30, _('Other feedback')),

)

This is then used in a form:
class HelpFeedbackForm(forms.Form):

#form for user to submit their feedback when not logged in

subject = forms.CharField(widget=forms.Select(choices=SUBJECT))

This is then presented in the template as:
{{ form.subject }}

which produces: "Problemas para el Inicio de Sesión o relacionados con la Cuenta" as mentioned above.

The translations are returned from the django.po file, but all of the HTML entity codes are returned as is, in the Select box in the template.

Also, use of the safe template filter tag does affect this and the string is still rendered with accents.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top