Migration Django 1.7 not matched

Using Django 1.7 and the new migration I am having a strange problem.

I divided my settings files into 3 files, which I always did before version 1.7, for example ...

/settings
  __init__.py
  base.py
  development.py
  production.py

__ __ INIT. RU

from .base import *

if sys.argv[1] == 'runserver':
    from .development import *
else:
    from .production import *

Both development.pyand production.pyhave their own settings for the database environment. However, with the new migration, the system performing the migration does not detect anything IF I did not put the database parameters in the files base.py.

Should I change this line as follows:

 if sys.argv[1] == 'runserver' or sys.argv[1] == 'migrate':

Or is there a better way?

+4
source share
1 answer

, che --settings , :

./manage.py --settings=project.settings.development runserver

DJANGO_SETTINGS_MODULE , Django.

:

export DJANGO_SETTINGS_MODULE=project.settings.development

DJANGO_SETTINGS_MODULE = project.settings.production.

, .

virtualenv wrapper, hook postactivate - :

#!/bin/bash
# This hook is run after this virtualenv is activated.
export DJANGO_SETTINGS_MODULE=project.settings.local
cd /home/user/develop/git/project

,

, ​​ .

base.py , development.py( production.py) - :

from .base import *

DATABASES = ... customize DB settings used for development/production ...
+3

All Articles