10.3.3 Post Data

The data migration for creating Post objects is almost exactly the same process, but comes with an added difficulty. This migration depends on the existence of the last two migrations we built. There is no way for Django to know this, and so for the first time we will modify the dependecy attribute of the Migration class.

Start by invoking makemigrations with the --empty flag and the --name option on the blog app, as shown in Example 10.18.

Example 10.18: Shell Code

$ ./manage.py makemigrations --empty --name=post_data blog

This code creates the 0002_post_data.py file. Note that previously we had programmed 0002_tag_data.py and 0003_startup_data.py. This is not a naming or migration order conflict—previous ...

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.