这有效:
def index(request):
try:
# Do some stuff
except:
return render(request, 'something.html')
但我怎样才能捕捉到错误:django.http.request.DisallowedHost?
已经尝试过这个,但它不起作用:
from django.core.exceptions import DisallowedHost
def index(request):
try:
# Do some stuff
except DisallowedHost:
return render(request, 'something.html')
慕斯709654
三国纷争
犯罪嫌疑人X
相关分类