如何将错误异常消息传递到网页上。我正在使用Atom文本编辑器和django
你知道吗视图.py你知道吗
try:
netconnect = ConnectHandler(**devices)
except (AuthenticationException):
re = print ('Authentication failed ' + ipInsert)
return render(request,'first_app/forms.html', {'form': form, 'reprinting':re})
你知道吗表单.html你知道吗
{% if request.POST %}
<pre>{{ reprinting }}</pre>
{% endif %}
它的pritingNone而不是用代码打印错误消息。你知道吗
你知道吗注:尽管描述的错误消息正在文本编辑器的命令行上打印
有关完整代码,请参阅以下链接: full code
^{} [Python-doc]函数不返回内容。它将值打印到标准输出通道,并返回
None
。你知道吗如果希望
re
包含错误消息,则需要分配它,如:请注意,您应该检查:
因为POST请求可以为空,但它仍然是POST请求。你知道吗
这应该够了
相关问题 更多 >
编程相关推荐