Current time: 04-23-2014, 03:07 PM Hello There, Guest! (LoginRegister)

Post Reply 
500 errors from Django admin url with tutorial app [SOLVED]
02-13-2011, 10:30 PM (This post was last modified: 02-13-2011 11:38 PM by DjinnE.)
Post: #1
500 errors from Django admin url with tutorial app [SOLVED]
I'm hoping someone ran into a similar issue and has a fix/workaround for this:

I'm trying to setup my first Django app on dreamhost, and am running into 500 errors when attempting to load <mysite>/admin/
the errors seem to be coming from Apache and not Python/Django. the error log contains the following 2 lines for each page load attempt:

[Sun Feb 13 21:25:03 2011] [error] [client <my client ip>] Premature end of script headers: admin
[Sun Feb 13 21:25:03 2011] [error] [client <my client ip>] Premature end of script headers: internal_error.html


and the access log this:
<my client ip> - - [13/Feb/2011:21:25:03 -0800] "GET /admin/ HTTP/1.1" 500 691 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13"
<my client ip> - - [13/Feb/2011:21:25:03 -0800] "GET /favicon.ico HTTP/1.1" 304 172 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13"


I've even tried a clean install of Django on a new sub-domain - using passenger, as describe here: http://wiki.dreamhost.com/Django - and followed the 'Polls' tutorial app instructions through to the top of this section: http://docs.djangoproject.com/en/dev/intro/tutorial02/ and still get the same error. If I remove the
'polls',
line from INSTALLED_APPS in settings.py, the admin site load correctly.

If I leave the 'polls' line in settings.py and launch a server via:
$ ./manage.py runserver <my site>:8080
and load <mysite>:8080/admin/ then the admin site also loads correctly, with Polls correctly installed, etc. So the same code works via runserver and does not work via passenger_wsgi.

Does anyone have any ideas how to fix or further diagnose this?
Find all posts by this user
Quote this message in a reply
02-13-2011, 11:34 PM
Post: #2
RE: 500 errors from Django admin url with tutorial app
Mystery solved. In case anyone runs into the same:

I ran django-setup.py in my ~/<mysite>/ directory, which created a sub directory for my project... ~/<mysite>/<myproj>

I placed polls in this new sub-directory: ~/<mysite>/<myproj>/polls

passenger_wsgi.py was adding the current working dir (e.g.: ~/<mysite>/) to the path, so polls was not in the path.

So the solution was any one of the following 3 changes:
  1. change settings.py to <myproj>.polls instead of just polls in INSTALLED_APPS
  2. bring polls up a level to ~/<mysite>/polls
  3. change passenger_wsgi.py to add ~/<mysite>/<myproj>/ to the path
Find all posts by this user
Quote this message in a reply
04-09-2012, 05:48 PM
Post: #3
RE: 500 errors from Django admin url with tutorial app
Thank you so much for posting this. Was exactly my problem.

(02-13-2011 11:34 PM)DjinnE Wrote:  Mystery solved. In case anyone runs into the same:

I ran django-setup.py in my ~/<mysite>/ directory, which created a sub directory for my project... ~/<mysite>/<myproj>

I placed polls in this new sub-directory: ~/<mysite>/<myproj>/polls

passenger_wsgi.py was adding the current working dir (e.g.: ~/<mysite>/) to the path, so polls was not in the path.

So the solution was any one of the following 3 changes:
  1. change settings.py to <myproj>.polls instead of just polls in INSTALLED_APPS
  2. bring polls up a level to ~/<mysite>/polls
  3. change passenger_wsgi.py to add ~/<mysite>/<myproj>/ to the path
Find all posts by this user
Quote this message in a reply
01-06-2013, 12:31 AM
Post: #4
RE: 500 errors from Django admin url with tutorial app [SOLVED]
Thanks, this was helpful.
I'm having the same problem with south.
If I put the south directory under my_proj then the site loads but manage.py cannot run south.
If I move south anywhere else, the site does not load, unless i remove south from my installed apps.
I tried placing south in home/user/lib/python and setting PYTHONPATH but that does not work and PYTHONPATH seems to get deleted when I do a pkill python.
Also tried adding south to passenger_wsgi.py (i.e. sys.path.insert(0,'/home/my_site/lib/python/South-0.7.6-py2.6.egg')) without success.

Any suggestions?
Find all posts by this user
Quote this message in a reply
12-16-2013, 02:41 AM (This post was last modified: 12-16-2013 02:43 AM by Baz_.)
Post: #5
RE: 500 errors from Django admin url with tutorial app [SOLVED]
Any chance you live in Ireland DjinnE, because I most definitely owe you a pint. I don't think that I would have come up with that solution myself, even though I should really have considered it. It's a bit ridiculous that you get no error feedback but there you go, you solved it without it and you are now owed one beer token!

Thanks very much!

If anyone is seeking advice in relation to which solution to use, I would advise solution one as it requires only one change and will ensure that future added application don't fall prey to the same problem, for example if you forget to add the mysite.new app in the settings and models files.

To implement this solution I added the line: sys.path.append("/home/user_name/my_site/my_project/")
immediately after: sys.path.append(os.getcwd())

I wasn't sure if it was possible to add them on the same sys.path.append() call so I just separated them out for certainty.

(As you can see from my post count, I registered especially to say thank you)
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: