1

I'm trying to run a new migration on a new Django 1.9 project but I'm getting an ImportError that seems to conflict with runserver. I'm running these commands from the <project> directory which includes the manage.py file.

Details:

  • Django 1.9
  • Using cookiecutter-django
  • runserver references the settings file
  • migrate produces an import error
  • In my local .env file, I have DJANGO_SETTINGS_MODULE=config.settings.local
  • Settings are in <project>/config/settings/...
  • I am running the project from within a virtualenv

Commands & Error:

$ django-admin.py migrate --settings=config.settings.local
.....
ImportError: No module named config.settings.local



$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

January 09, 2016 - 13:33:32
Django version 1.9, using settings 'config.settings.local'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Any ideas? Thanks in advance!

pydanny
  • 7,954
  • 6
  • 34
  • 42
Emile
  • 3,464
  • 8
  • 46
  • 77
  • Er, because you're passing settings to migrate but not to runserver. Why don't you run migrate with manage.py like you do runserver? – Daniel Roseman Jan 09 '16 at 21:48

1 Answers1

2

Use manage.py instead of django-admin.py

python manage.py migrate --settings=config.settings.local
Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • That answered it. I'll mark it correct once I can - thanks for the help, really appreciate it! – Emile Jan 09 '16 at 21:49