Problems with Virtualenv and Django 1.4 -- deployment on uwsgi.

464 views
Skip to first unread message

Maciej Szlosarczyk

unread,
Apr 3, 2012, 12:01:19 PM4/3/12
to Django users
Since I've upgraded the version of Django and started a new project on
it, I cannot make it work properly with uwsgi.

The problem is that django doesn't import apps from project tree. My
settings.py looks like this:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
#Practical apps:
'engine.blog',
)

My config for uwsgi looks like this (parsed by yaml):

uwsgi:
uid: www-data
gid: www-data
socket: /tmp/wsgi_dev.sosek.net.sock
module: django.core.handlers.wsgi:WSGIHandler()
chdir: /home/sosek/nginx/dev.sosek.net/apps/engine
env: DJANGO_SETTINGS_MODULE=engine.settings
virtualenv: /home/sosek/.virtualenvs/dev.sosek.net
pythonpath: /home/sosek/nginx/dev.sosek.net/apps

When I use from inside of the virtualenv "python manage.py runserver"
i get something like:
Error: No module named blog

For UWSGI, most recent calls look like this:
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/site-
packages/django/template/defaultfilters.py", line 718, in date
return format(value, arg)
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/dateformat.py", line 310, in format
return df.format(format_string)
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/dateformat.py", line 33, in format
pieces.append(force_unicode(getattr(self, piece)()))
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/dateformat.py", line 214, in r
return self.format('D, j M Y H:i:s O')
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/dateformat.py", line 33, in format
pieces.append(force_unicode(getattr(self, piece)()))
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/encoding.py", line 71, in force_unicode
s = unicode(s)
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/functional.py", line 121, in __unicode_cast
return func(*self.__args, **self.__kw)
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/__init__.py", line 86, in
ugettext
return _trans.ugettext(message)
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/trans_real.py", line 278, in
ugettext
return do_translate(message, 'ugettext')
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/trans_real.py", line 268, in
do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/trans_real.py", line 183, in
translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/translation/trans_real.py", line 160, in
_fetch
app = import_module(appname)
File "/home/sosek/.virtualenvs/dev.sosek.net/local/lib/python2.7/
site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named blog
[pid: 7174|app: 0|req: 4/4] 78.8.143.124 () {40 vars in 1834 bytes}
[Tue Apr 3 17:54:33 2012] GET / => generated 0 bytes in 42 msecs
(HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
Message has been deleted

Roberto De Ioris

unread,
Apr 3, 2012, 12:40:54 PM4/3/12
to django...@googlegroups.com

you should update your module directive to

module: engine.wsgi

Check latest official Django docs on uWSGI

https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/uwsgi/

--
Roberto De Ioris
http://unbit.it

Reply all
Reply to author
Forward
0 new messages