[Fixed]-Django User and AbstractBaseUser

1👍

you better use ForeignKey in Post Model, since one person can have many posts, right?

class Profile(models.Model):
    user = models.OneToOneField(User, related_name="user_profile")
    ...

class Post(models.Model):
    user = models.ForeignKey(Profile, related_name="user_posts")

and you dont set AUTH_USER_MODEL, you set it if you want to customize the authentication backend, I think you want to use django’s built-in User Model to authentication. so no need for AUTH_USER_MODEL in settings

with the models above, you can access profile in views like this:

user_profile = request.user.user_profile
user_profile.keywords
...

and in admin, you just need to create another new django user object, to be able to assign it to a new user profile object.

Leave a comment