Opened 16 years ago

Last modified 6 years ago

#10449 new

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

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
Pull Requests:How to create a pull request

Description (last modified by Alex Gaynor)

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.

According to the ticket's flags, the next step(s) to move this issue forward are:

  • To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is: [https://github.com/django/django/pull/#### PR].

Change History (1)

comment:1 by Alex Gaynor, 16 years ago

Description: modified (diff)

Please use the preview button.

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