November 2015
Beginner to intermediate
840 pages
26h 30m
English
slug to NewsLinkAdding a SlugField to NewsLink is really easy, given Django’s declarative syntax, as shown in Example 10.21.
Example 10.21: Project Code
organizer/models.py in 89c25fd8a8
70 class NewsLink(models.Model): . ... 72 slug = models.SlugField(max_length=63)
That’s it! You’re done. (Take heed: we have not set the unique option on the field.)
Mirroring this change in the database and making the lives of your future self and your coworkers easy is a little trickier, especially because we have a database with data in it.
When we call makemigrations, Django compares the current state of our models with the historical models it builds thanks to the Apps and AppConfig classes. It ...
Read now
Unlock full access