Sam Hooke

These are rough notes from whatever I was working on, interested in or thinking about at the time. They vary greatly in quality and length, but prove useful to me, and hopefully to you too!

Run Django makemigrations as tox task

The following is an example Windows batch script which runs makemigrations inside a tox virtual environment, then copies the migrations out of the virtual environment into your src directory. This is very useful for making changes to your Django model and generating the migrations on your Windows development machine. It would be straight-forward to convert this to run on Linux too.

REM Ensure the py36 virtualenv present
tox -e py36 --notest

REM Activate the py36 environment
call .tox\py36\Scripts\activate.bat

REM Execute the makemigrations command
REM (Lots of quote escaping going on!)
python -c "from import execute_from_command_line; execute_from_command_line([\"\", \"makemigrations\", \"--settings=my_django_app.settings\"])"

REM Copy the migrations from the py36 virtualenv into the src
copy /Y .tox\py36\Lib\site-packages\my_django_app\migrations\* src\my_django_app\migrations\
<< Previous: New dependency font(:lang-en) required by fontconfig-2.10.95-11
Next: Invalid handle error from Coverage inside Tox >>