[Answer]-Django 1.7 + Django CMS – drop migration files from my repo or include virtualenv in repo?

0👍

The problem is in my django settings.py file:

MIGRATION_MODULES = {
    'cms': 'cms.migrations_django',
    'menus': 'menus.migrations_django',
    'djangocms_file': 'djangocms_file.migrations_django',
    ...
}

I had to introduce the above to get django-cms 3.0.6 to work with django 1.7, a consequence of the fact that migrations in django 1.7 are no longer done with South, as django 1.7 now has it’s own migration system, while cms 3.0.6. still expects migrations to be managed by South by default.

However, the effect of the above config is to store migrations in the above described paths which in my case pointed straight to the virtual env. Thus migration info was getting stored within the virtual env dir, leading to problems in deploying to production.

To fix this I modified my project directory structure to include a folder called “migrations”:

myproject/manage.py
myproject/migrations/
myproject/myproject/
...

And modified the config to be:

MIGRATION_MODULES = {
    'cms': 'migrations.cms.migrations_django',
    'menus': 'migrations.menus.migrations_django',
    'djangocms_file': 'migrations.djangocms_file.migrations_django',
    ...
}

This has the effect of now storing all migration files in the django project itself (and by extension the git repo). As migration info is no longer in the virtual env directory, there is no longer any reason to consider the rather unattractive possibility of including the virtual env in the repo.

1👍

You never commit the virtual env, it defeats the purpose; you just add unnecessary content to git.

Instead, freeze the requirements and commit the file:

pip freeze > requirements.txt

Install the packages on the server:

pip install -r requirements.txt
👤Pran

Leave a comment