During the development of a Django model on your local machine is it often necessary to refine the most recent migration to cope with updates to the model, without polluting the migrations of the app with a new migration for each local update.
South had the update flag for the schemamigration command, but I didn’t find a similar functionality in the Django builtin makemigrations command introduced in Django 1.7.
So I put togheter a simple bash script to automate the process.
Basically the script unapplies the last migration for a given app, update the migration and reapplies it. I find it a little time saver and it feels good to know that the script is doing the right things in the right order.
You may also like:
How to add a group choice combo box in a Django user profile form
Assume that you have a Django project where each user belongs to just one group, say Registered or Admin, but not both. You want to show a form in your front-end to let Admin users edit the user profiles, where each user profile is made with First name, Last name …
A Django custom command to write model fields on an Excel file
Suppose you need to write down your model fields on an Excel file, for example to complement the documentation of your code. Django has built in functions to introspect models and fields of an app, and you can leverage this API to have the information you need. You can use …