Reputation: 423
I am trying to pass a variable to a url in an error message. How can I implement this?
In views.py
error_messages = {
'inactivated': _('Please <a href="../send" click here to
to receive an activation key.')
}
I'd like to pass an email address to the send url when a user gets an inactivated error message and click the link.
Upvotes: 2
Views: 1533
Reputation: 661
You could pass the variable as an URL:
In views.py
context_data = {'retry_url': reverse(viewname="send_activation_email", args=(), kwargs={})}
return render(
request, template_name="template.html", context=context_data)
In template.html:
<p><a href="{{ retry_url }}">click here</a> to receive an activation key.</p>
Upvotes: 0
Reputation: 731
String formatting should work
foo = 'fooo'
bar = 'baar'
'%s %s' % (foo, bar)
>> 'fooo baar'
Upvotes: 3