def raise_no_permission_exception(self, instance=None):
from django.template import Context, Template
t = Template("""
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
No permission to perform this action
{% if instance %}
<br/>
<a href="{% url 'wf_detail' instance.pk %}"> View this process </a>
{% endif %}
</body>
</html>
""")
http_response = HttpResponse(
t.render(Context({"instance": instance})), content_type='text/html', status=403)
raise HttpResponseException(http_response)
评论列表
文章目录