Error In Creating Custom 404 Error Page!


#1

As Soon as I make a Custom 404 page. All my page loses the CSS decorations.
When I turn DEBUG = False and set ALLOWED_HOSTS = [’*’] everything works fine. But as soon as I fill something in 400.html the Website Loses all Its CSS decorations.


#2

Post your code.


#3

Thanks for the reply. I fixed it. Code was alright. The problem was that Django doesn’t handle static data when Debug is False. Using manage.py runserver --insecure fixed it. But can anyone please explain me the reason behind it? Why does I need to run server in insecure mode to access my static files?


#4

Oh fun, good catch! You’re right about Django and static data and DEBUG=false. Django doesn’t serve static files when DEBUG is false because it’s super inefficient and it assumes, if DEBUG is false, you have a production web server that handles everything for you so it doesn’t need to serve those files any more.

Once you deploy though to Heroku (if you’re following those instructions), Heroku will correctly keep serving your static files so this is only an issue locally. :)


#5

Thanks for the help! Yeah, I am following your book. Even got the intermediate edition. Just didnt deploy the web app yet. Its not complete, trying to make individual profile for each user and make a graph based on a field that they input (say weight!). Really confused about the graph thing. Any suggestions?


#6

Cool, so your static files should work when deployed. :)

As for the graph, you’ll probably want to save the inputted fields under their own model along with the date for each input, which you can then graph using something javascripty like http://www.flotcharts.org/

Graph might be complicated at first — I would experiment with a MVP (minimum viable product) of using a table to display data, and then you can evolve it into a graph. :)