سؤال

I have a Django project which was deployed on a staging server under Apache2 and mod_wsgi, and it was working fine. It uses the django-registration application.

I tried to switch my server over to nginx and to run the Django project with gunicorn. The project was loaded up fine, except when I tried to reach /admin and /user/logout (default is /account with django-registration) it would give me a "No module named urls" error. I tore my hair out for hours. I commented out the registration url line in urls.py and then admin showed up fine, except it was missing the registration models. So admin was only failing because registration was failing.

Ideally I'd like to push out my project into production using the nginx/gunicorn setup, but registration doesn't seem to want to play nicely. I tried removing registration, installing 0.8 from source, removing that, pip installing 0.7, nothing worked. What worked was stopping nginx and then running apache again. So essentially, the project is untouched save for the type of web server being used.

Since registration seems to be working fine under Apache/mod_wsgi, I'm tempted to just push to production with that setup... but I'm still curious to know why registration just won't work with gunicorn when I try. Any help would be appreciated.

هل كانت مفيدة؟

المحلول

Sounds like your sys.path is setup differently when using mod_wsgi. It's a pretty common mistake to run into when deploying so a good first step would be checking your sys.path when running gunicorn. Are you using virtualenv? Make sure to install gunicorn into your virtualenv as well as django-registration and any other dependencies you might have. If you run the gunicorn script in your virtualenv's bin dir everything should just work.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top