Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrations in stand alone Django app

How do I makemigrations on a stand alone Django app (ie one that is not part if any project).

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

like image 898
Alex Rothberg Avatar asked Dec 24 '22 18:12

Alex Rothberg


1 Answers

You can do it similar to how you do testing scripts for apps:

#!/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')
like image 198
C. Trudeau Avatar answered Jan 04 '23 13:01

C. Trudeau