apache - Django Import errors on production environment -


i have trouble run django project on production server apache , mod_wsgi. error happened when i'm start apache , go site first time or go other:

importerror @ /
exception value: cannot import name myname
exception location /var/www/projectname/appname/somemodule.py

when i'm reload page error disappears , site work fine. point error happened selectively , sometime not appear.

in project i'm use imports without project name prefix (i mean 'from accounts.models import account' instead 'from projectname.accounts.models import account').

on development (manage.py runserver) server work fine without troubles.

i have used many variations of apache , wsgi script configurations problem not solved.

here current projectname.wsgi:

#!/usr/bin/env python import os, sys, re  sys.path.append('/var/www/projectname') sys.path.append('/var/www')  os.environ['python_egg_cache'] = '/var/www/projectname/.python-egg' os.environ['django_settings_module'] = 'settings'  import django.core.handlers.wsgi application = django.core.handlers.wsgi.wsgihandler() 

here parts apache config:

<virtualhost ip:80>     serveradmin admin@server.com     documentroot /var/www     servername www.projectname.com     wsgiscriptalias / "/var/www/projectname/projectname.wsgi"      wsgidaemonprocess projectname threads=5 maximum-requests=5000      <directory />         options followsymlinks         allowoverride none     </directory>      <directory /var/www/>         options indexes followsymlinks multiviews         allowoverride none         order allow,deny         allow     </directory>     .... 

also i'm use separate virtual host ssl.
hope me.
thanks!

when had problem, post https://stackoverflow.com/a/10601523/1782780 pointed me towards answer: had bug in module further chain.

as michal explains in post:

python not select 1 class administrative/models.py file. instead python interpreter reads entire file, creates module object, executes code imported file in new modules namespace, , copies name contract new module's namespace current namespace. so, although seems importing 1 class module, error anywhere in module can prevent successful import - in case error class contractform. rest of traceback details went wrong class.

so further in traceback , might find problem.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -