Adding extended Profile model into custom user models admin

后端 未结 1 1039
情书的邮戳
情书的邮戳 2021-01-21 13:24

How can i add extended Profile model fields (fields which are not available in custom user model fields) into custom users admin users.admin?

相关标签:
1条回答
  • 2021-01-21 14:09

    I would recommend that you override the User model.

    from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, \
                                            PermissionsMixin
    class UserManger(BaseUserManager):
        """
           Add extra calling functionalities here
        """
        pass
    
    
    class User(AbstractBaseUser, PermissionsMixin):
        """Custom user model"""
        pass
    
        objects = UserManger()
    
    

    This is the basic format. Add the extra profile fields in the model

    in setting.py add

    AUTH_USER_MODEL = '{{ app_name }}.{{ model_name }}'
    # eg. 'core.User'
    
    0 讨论(0)
提交回复
热议问题