Thursday, April 25, 2013

Re: Unexpected Server Error (500) in tutorial

Django 1.5 made a change with
https://docs.djangoproject.com/en/1.5/releases/1.5/#allowed-hosts-required-in-production

"The new ALLOWED_HOSTS setting validates the request's Host header and protects against host-poisoning attacks. This setting is now required whenever DEBUG is False, or else django.http.HttpRequest.get_host() will raise SuspiciousOperation. For more details see the full documentation for the new setting."

Full ALLWED_HOSTS documentation
https://docs.djangoproject.com/en/1.5/ref/settings/#std:setting-ALLOWED_HOSTS

On Thursday, April 25, 2013 12:41:12 PM UTC-5, dsmak...@gmail.com wrote:
I am running python 3.3.1, django-dev, Windows 7,

dev version of tutorial part 3 -
     Customizing Error Views  
     The 404 (page not found) view

The suggested code works as expected though I have some quibbles about documentation wording.

BUT...

When in settings.py DEBUG= True, django prints the stack trace plus a note advising that this view is displayed because DEBUG is set to True.

In settings.py, I see:
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

Makes sense, besides I have created a 404.html and put it in the right place, and I want to see it displayed

When I Set DEBUG=False, I then get "Server Error (500)" not 404.

With some experimentation, I discovered that if I set DEBUG=False the tutorial app appears to always fail with Server Error 500. As a test, I went back to tutorial part 1. created a new minimal project, confirmed that it worked, then set DEBUG=False. and voila I get Server Error (500) again.

That is:
  • DEBUG = True, in debug mode - the code works without error
  • DEBUG = False, in production mode - the code fails Server Error (500)
Aside from my setting DEBUG to False, this is all django generated code.

I am a django newbie, but this feels like a bug.  

Checking the IRC archives I see more than one question about cryptic Server Error (500) occurrences.

Comments?




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment