Forums

Django custom 404 page not working

my 404 page working fine on development server but when i tried it on pythonanywhere after deployment it shows

Something went wrong and the log doesn't help much


server.log file:

2020-08-09 20:09:29   File "/usr/lib/python3.7/logging/handlers.py", line 940, in emit#012    
self.socket.sendto(msg, self.address)
2020-08-09 20:09:29 OSError: [Errno 9] Bad file descriptor
2020-08-09 20:09:29 #012During handling of the above exception, another exception occurred:
2020-08-09 20:09:29 Traceback (most recent call last):
2020-08-09 20:09:29   File "/usr/lib/python3.7/logging/handlers.py", line 940, in emit#012    self.socket.sendto(msg, self.address)
2020-08-09 20:09:29 OSError: [Errno 9] Bad file descriptor
2020-08-09 20:09:29 #012During handling of the above exception, another exception occurred:
2020-08-09 20:09:29 Traceback (most recent call last):
2020-08-09 20:09:29   File "/usr/lib/python3.7/logging/handlers.py", line 940, in emit#012    self.socket.sendto(msg, self.address)
2020-08-09 20:09:29 OSError: [Errno 9] Bad file descriptor
2020-08-09 20:09:29 #012During handling of the above exception, another exception occurred:
2020-08-09 20:09:29 Traceback (most recent call last):
2020-08-09 20:09:29   File "/usr/lib/python3.7/logging/handlers.py", line 940, in emit#012    self.socket.sendto(msg, self.address)
2020-08-09 20:09:29 OSError: [Errno 9] Bad file descriptor
2020-08-09 20:09:29 #012During handling of the above exception, another exception occurred:
2020-08-09 20:09:29 Traceback (most recent call last):
2020-08-09 20:09:29   File "/usr/lib/python3.7/logging/handlers.py", line 940, in emit#012    self.socket.sendto(msg, self.address)
2020-08-09 20:09:29 OSError: [Errno 9] Bad file descriptor
2020-08-09 20:09:29 #012During handling of the above exception, another exception occurred:
2020-08-09 20:09:29 Traceback (most recent call last):
2020-08-09 20:09:29   File "/usr/lib/python3.7/logging/handlers.py", line 940, in emit#012    self.socket.sendto(msg, self.address)
2020-08-09 20:09:29 OSError: [Errno 9] Bad file descriptor

How does your code look like?

what file specifically ?

That looks like you're calling django.setup somewhere in your web app code. It is not necessary to call djsngo.setup in a web app and it breaks the logging that we have set up.

yes indeed i was using django.setup problem solved after removing it interesting info to know django.setup could break logs thank you !