Python 警告消息应包含指向下一页的链接

Python 警告消息应包含指向下一页的链接,python,django,django-templates,Python,Django,Django Templates,如果用户没有用户名,我会在他们的个人资料页面上显示一条警告消息。在其中,我想设置一个链接到一个页面,用户可以设置他们的用户名。我已经这样做了,但是a href显示为一个字符串。有什么问题 messages.warning(request, 'WARNING! You have not set your custom URL for this profile. You can set this <a href="{% url change_url %}">HERE.</a>

如果用户没有用户名,我会在他们的个人资料页面上显示一条警告消息。在其中,我想设置一个链接到一个页面,用户可以设置他们的用户名。我已经这样做了,但是a href显示为一个字符串。有什么问题

messages.warning(request, 'WARNING! You have not set your custom URL for this profile. You can set this <a href="{% url change_url %}">HERE.</a>')
messages.warning(请求“warning!您尚未为此配置文件设置自定义URL。您可以设置此URL”)

消息只是字符串,而不是模板指令。要获取您的url,您应该使用:


还是一样的结果。它呈现a href标记too@mangobug如何在模板中输出消息?请参阅edits.in在base.py文件中,我只是将消息放在一个循环中,并呈现它{{message}}

from django.core.urlresolvers import reverse    

messages.warning(request, 'WARNING! You have not set your custom URL for this profile. You can set this <a href="%s">HERE.</a>' % reverse('change_url'))
{{ message | safe }}