10.4.1 Making Our Lives Difficult with a Data Migration

Before we actually create a migration for adding a SlugField to NewsLink, I want to make life more difficult to better replicate real-world conditions. To that end, I want the database to already have NewsLink data, which will force us to build our schema migration in the next section with this in mind.

As with Tag, Startup, and Post, we first create the data migration by invoking makemigrations, as shown in Example 10.20.

Example 10.20: Shell Code

$ ./manage.py makemigrations --empty --name=newslink_data organizer

This code creates the 0004_newslink_data.py file in organizer/migrations/.

The NewsLink data migration is very straightforward: there’s no need ...

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.