November 2015
Beginner to intermediate
840 pages
26h 30m
English
Given that we are allowing specific users to write blog posts, it would be nice if we identified which blog post was written by which user. We can connect our Post to the User model exactly as if we had never customized it, as shown in Example 22.54.
Example 22.54: Project Code
1 from django.conf import settings . ... 12 class Post(models.Model): . ... 18 author = models.ForeignKey( 19 settings.AUTH_USER_MODEL, 20 related_name='blog_posts')
Hopefully, our dependency on the use of get_user_model() and relations built using the setting.AUTH_USER_MODEL is a lot clearer than before. We won’t always know which ...
Read now
Unlock full access