1

I manage to successfully install mysql. But when I try to run following command -python manage.py makemigrations -python manage.py syncdb It gave me this error.

import error: no module named python.settings

My wsgi.py file contains

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Portfolio.settings")

application = get_wsgi_application()

P.S:I am working on ubuntu 14.04, in addition there is same error in python manage.py runserver command.

1 Answer 1

3

I am running a similar server setup (Ubuntu 14.04, Apache, mod_wsgi) and in our wsgi.py file we had to do two things to make sure it worked. We used an import of the top level app directory, and also had a multi-file (not django default) settings structure and had to adjust the specification of our settings file.

For example, our folder structure is:

project-directory
- manage.py
- static
- app1-directory
   - settings # a directory, not a file
       - development.py
       - quality_assurance.py
       - production.py
   - wsgi.py
- app2-directory

in the wsgi.py file we needed to include this directive immediately before the setdefault line:

import sys
sys.path.append(os.path.dirname(os.path.dirname(__file__)))

The second change that we made was to specify the exact settings file, so instead of "app1-directory.settings" we use this as an example:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app-name.settings.quality_assurance")
Sign up to request clarification or add additional context in comments.

1 Comment

It looks like your problem may also potentially be due to a namespace collision: stackoverflow.com/questions/7367577/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.