custom django-user object has no attribute 'has_module_perms'

后端 未结 3 1086
刺人心
刺人心 2021-02-12 07:00

My custom user model for login via email:

class MyUser(AbstractBaseUser):
    id = models.AutoField(primary_key=True)  # AutoField?
    is_superuser = models.Int         


        
3条回答
  •  孤街浪徒
    2021-02-12 07:58

    I think your model is missing some attributes such as 'has_module_params'...Try to add the following

    class MyUser(AbstractBaseUser):
      ...
      ...
    
      def has_perm(self, perm, obj=None):
        return self.is_superuser
    
      def has_module_perms(self, app_label):
        return self.is_superuser
    

提交回复
热议问题