In fact, you do not need to have a project, all you need is a settings file and a script that starts the migration creation. Settings should contain the following (minimum):
# test_settings.py DEBUG = True SECRET_KEY = 'fake-key' INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'your_app' ]
And the script that does the migration should look like this:
# make_migrations.py import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_settings") from django.core.management import execute_from_command_line args = sys.argv + ["makemigrations", "your_app"] execute_from_command_line(args)
and you should run it python make_migrations.py . Hope this helps someone!
source share