Migrations in a standalone Django app

How to do makemigrations on a separate Django application (i.e. one that is not part of any project).

For example, after: https://docs.djangoproject.com/en/1.8/intro/reusable-apps/

+3


source to share


2 answers


You can do this in a similar way to how you test scripts for applications:



#!/usr/bin/env python

import sys
import django

from django.conf import settings
from django.core.management import call_command

settings.configure(DEBUG=True,
    INSTALLED_APPS=(
        'django.contrib.contenttypes',
        'your_app',
    ),
)

django.setup()
call_command('makemigrations', 'your_app')

      

+5


source


What I do is create a layout project containing only this application, then the process will be as usual:



manage.py makemigrations myapp

      

+1


source







All Articles