Se eu usar get_object_or_404()
, O Django mostra minha página de erro correta, mas o NGINX ainda retorna:
HTTP/1.1 200 OK
Server: nginx
tl; tr
Cada página retorna 200 ou (se 500) tempo limite. O que há de errado aqui?
NGINX conf:
location / {
proxy_pass http://unix:/opt/repo/page.sock;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
}
urls.py
from django.conf import settings
handler404 = "my_app.views.page_not_found"
Respostas:
1 para resposta № 1Você deve configurar os manipuladores, isso pode ser feito desta maneira:
from django.utils.functional import curry
handler404 = curry(page_not_found, template_name="404.html")
handler500 = curry(page_not_found, template_name="500.html")
handler403 = curry(page_not_found, template_name="403.html")
Eu fiz isso no meu urls.py, mas também pode ser feito em s