from django.contrib.auth import get_user_model
from django.contrib.auth.models import AbstractUser
class MyUser(AbstractUser):
pass
class Landlord(models.Model):
user = models.OneToOneField(get_user_model(), on_delete=models.CASCADE)
#other fields
def __str__(self):
# **Error is here**
return self.user.email
When I use email field of my user it has give this error: "Instance of 'OneToOneField' has no 'email' member"
what is the reason for error?(And what fields are there in AbstractUser class?) How can I fix the error.
I am using AbstractBaseUser instead of AbstractUser and the problem didn't come up. also by reading the code of django.contrib.auth.models you can see what fields have been implemented and how. it can be done by holding the control key and clicking on the import address.