Manager isn't available; User has been swapped for 'pet.Person'

前端 未结 4 662
误落风尘
误落风尘 2020-11-28 05:55

I\'m been using the default user model in django for quite a abit and I realize , if I need to further enhance it , I would have to create my own custom User Model in django

4条回答
  •  伪装坚强ぢ
    2020-11-28 06:09

    The problem is that User refers to django.contrib.auth.models.User and now you have got a Custom User pet.Person assuming you have in the settings.py

    AUTH_USER_MODEL = "pet.Person"
    

    you have to define User with the Custom User model and you can do this with get_user_model at the top of the file where you use User

    from django.contrib.auth import get_user_model
    User = get_user_model()
    

    now you will be able to use Custom User model and the problem has been fixed.

提交回复
热议问题