views:

28

answers:

2

I need to throw ValidationError containing anchor.

if not profile.activated():
    raise ValidationError('Your profile is not activated. <a href="{% url resend_activation_key %}">Resend activation key</a>.')

What I need to modify to make this work?

A: 

First: just don't do this! Put HTML code where it belongs: into the template.

Second: you might be able to do this with

from django.template import Context, Template
t = Template(u"Your profile is not.... {% url blah %} ...")
raise ValidationError( t.render(Context())

But html tags will be escaped unless you mark them as safe in your template.

mawimawi
First note is sound. But how can I do this? Maybe by setting special form attribute?
feelgood
Isn't it possible for you to check the profile activation before you show the form at all?something like in your view: if request.method == "GET" and not profile.activated(): redirect_to_url_describing_problem
mawimawi
+3  A: 

Why do you want to use a template tag here? Template tags are for use in templates. If you want to find a reverse URL, use the reverse function.

Daniel Roseman