#24639: Interaction between ValidationError and mark_safe
----------------------------+------------------------
Reporter: jambonrose | Owner: jambonrose
Type: Bug | Status: new
Component: Forms | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+------------------------
Succinctly: the `ValidationError` message only respects `mark_safe` if the
`params` argument is not used.
Current behavior:
||= message =||= params =||= output =||
|| text || none || text ||
|| safe || none || safe ||
|| text || text || text ||
|| safe || text || text ||
|| text || safe || text ||
|| safe || safe || '''text''' ||
Given that, according to the
[https://docs.djangoproject.com/en/1.8/ref/forms/validation/#raising-
validationerror documentation], the best way to use `ValidationError` is
with the `params` argument, it seems desirable to enable using `mark_safe`
when using `params`, as this would enable us to code:
{{{#!python
# method for a Form subclass
def clean_slug(self):
new_slug = self.cleaned_data['slug'].lower()
if new_slug == 'invalid_value':
raise ValidationError(
# _ is ugettext
mark_safe(_('SlugField may not be '
'"%(slug_value)s" '
'for URL reasons.')),
params={
'slug_value':
mark_safe('<code>invalid_value</code>')})
return new_slug
}}}
I think desired behavior ought to be:
||= message =||= params =||= output =||
|| text || none || text ||
|| safe || none || safe ||
|| text || text || text ||
|| safe || text || text ||
|| text || safe || text ||
|| safe || safe || '''safe''' ||
For more information about the issue, please see
[https://groups.google.com/d/msgid/django-developers/4761844C-6BFE-
465A-9108-AFDA693A9E06%40andrewsforge.com my message on django-
developers].
--
Ticket URL: <https://code.djangoproject.com/ticket/24639>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.401bf394b4eb5913d8c8285c4f95ba42%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.