Duncan Parkes
Duncan Parkes

Reputation: 1953

What's the best way to make a new migration in a standalone Django app?

I have a Django app which was spun out a while ago from the project it was originally built for, made into a separate standalone app, and put on PyPI (https://pypi.python.org/pypi/mysociety-django-images). The app is built expecting to be run with Django 1.7+.

I'd now like to make a change to one of the models there - just changing a max_length on a field. I can't see anything in the documentation about how to make a new migration for it? Do I need to make an example project and use that, or is there a better way?

Upvotes: 4

Views: 244

Answers (1)

1ronmat
1ronmat

Reputation: 1177

You can do this by making a script like:

#!/path/to/your 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',
        'yourAppName',
    ),
)

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

(this is also how we go about testing our standalone apps).

I don't know which is the better practice between this and create an example project (this appears lighter to do).

Upvotes: 3

Related Questions