Oculus
Oculus

Reputation: 33

python manage.py migration not working and so does runserver

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.

Upvotes: 1

Views: 874

Answers (1)

WakingTheEchoes
WakingTheEchoes

Reputation: 31

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")

Upvotes: 3

Related Questions