10.3.2 Startup Data
Starting in Django 1.8, it became possible to pass the --name
argument to makemigrations
, allowing for the creation of a named empty migration file. Rather than creating a file (automatically named according to UTC date-time) and then renaming the file, we can issue a single commmand, as shown in Example 10.11.
$ ./manage.py makemigrations --empty --name=startup_data organizer
Every data migration is going to feature the structure: We use the RunPython
operation to call either a forwards or backwards Python function, as shown in Example 10.12.
organizer/migrations/0003_startup_data.py
in f492ab1462
132 dependencies ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.