smhk

Run Django `manage.py makemigrations` without a database

The makemigrations command does not require a database to be present. As such, it is actually quite straightforward to run makemigrations without even having a database. This can be very useful for the development cycle of: modifying model, run tests, update tests; without having to have a full deployment.

To run makemigrations when you don’t even have a manage.py, you can do the following. Assuming you are in the virtual environment with your Python package installed:

>>> from django.core.management import execute_from_command_line
>>> execute_from_command_line(["", "makemigrations", "--settings=my_module.settings"])

This will then create the new migration inside your Python package within the site-packages folder in your virtual environment.