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.
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 ...