Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: Could not import settings (Is it on sys.path? Is there an import error in the settings file?): No module named setting

I'm going through the "example" project into production on a VPS CentOS 6 (with Plesk) with python2.7, mod_wsgi, Django 1.6 I have proven many configurations and I always get error "No module named settings" or "No module named Unipath". Not that I have wrong or I'm missing. Thanks and regards.

My vhost.conf:

Alias /static/ /var/www/vhosts/example.com/httpdocs/
Alias /media/ /var/www/vhosts/example.com/httpdocs/media/

WSGIScriptAlias / /var/www/vhosts/example.com/example.wsgi

<Directory /var/www/vhosts/example.com>
    Order allow,deny
    Allow from all
</Directory>

My example.wsgi:

import os
import sys

path = '/var/www/vhosts/example.com/example'
if path not in sys.path:
   sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

I put my project via ftp into : /var/www/vhosts/example.com/

example.com/
      example(project)
          settings.py
          urls.py
          ...
      app
          models.py
          forms.py
          views.py
          ...
      templates
      httpdocs
      example.wsgi
      manage.py

Thanks again...

like image 419
user3356409 Avatar asked Feb 26 '14 15:02

user3356409


1 Answers

Your settings are in example app so it should be:

os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings'
like image 167
Łukasz Staniszewski Avatar answered Oct 05 '22 21:10

Łukasz Staniszewski