The latest version of Django removed the AdminMediaHandler class. This causes an import error with gunicorn 0.14.2.
2012-04-12 10:40:12  [INFO] Starting gunicorn 0.14.2
2012-04-12 10:40:12  [INFO] Listening at: unix:/tmp/gunicorn_site.sock (6414)
2012-04-12 10:40:12  [INFO] Using worker: sync
2012-04-12 10:40:12  [INFO] Booting worker with pid: 6440
2012-04-12 10:40:12  [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/home/sites/lib/python2.6/site-packages/gunicorn/arbiter.py", line 453, in spawn_worker
File "/home/sites/lib/python2.6/site-packages/gunicorn/workers/base.py", line 99, in init_process
self.wsgi = self.app.wsgi()
File "/home/sites/lib/python2.6/site-packages/gunicorn/app/base.py", line 101, in wsgi
self.callable = self.load()
File "/home/sites/lib/python2.6/site-packages/gunicorn/app/djangoapp.py", line 120, in load
mod = util.import_module("gunicorn.app.django_wsgi")
File "/home/sites/lib/python2.6/site-packages/importlib/__init__.py", line 37, in import_module
File "/home/sites/lib/python2.6/site-packages/gunicorn/app/django_wsgi.py", line 20, in <module>
from django.core.servers.basehttp import AdminMediaHandler
ImportError: cannot import name AdminMediaHandler
due to this commit from Django core
Fixed #18035 -- Removed deprecated AdminMediaHandler?, as per official deprecation timeline. Thanks Jannis Leidel and Ramiro Morales for the review.
no mre AdminMediaHandler class in django 1.4 . close #333
I have several instances of Django 1.4 running, and every one of them has AdminMediaHandler in place and gunicorn 0.14.2 works as a charm. From what I see in the commit in Django, the change was made in trunk after the 1.4 release, so it seems to be something for the future 1.5 release.
All this said, I'm not saying the fix to this issue is wrong, only that probably shouldn't apply to Django 1.4, but Django 1.5.
We could probably only detect if AdminHandler is present or not. @davisp @tilgovi thoughts?
detect if AdminHandler can be imported. close #333