Hi all,
newbie here!
I cannot access self.user.first_name and self.user.last_name in my ClientProfile class, this is the error message:
newbie here!
I cannot access self.user.first_name and self.user.last_name in my ClientProfile class, this is the error message:
Instance of 'OneToOneField' has no 'first_name' member
Instance of 'OneToOneField' has no 'last_name' member
What am I doing wrong?
class ClientProfile(models.Model): user = models.OneToOneField( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, ) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) created_date = models.DateTimeField(auto_now_add=True) modified_date = models.DateTimeField(auto_now=True)
def __str__(self): return '{} {}'.format(self.user.first_name, self.user.last_name) '
class ClientProfile(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
created_date = models.DateTimeField(auto_now_add=True)
modified_date = models.DateTimeField(auto_now=True)
def __str__(self):
return '{} {}'.format(self.user.first_name, self.user.last_name) 'AUTH_USER_MODEL = 'accounts.CustomUser' # Overriding the default User modelYou received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/209748b5-e51a-49b5-b37d-d1caed08a62d%40googlegroups.com.
No comments:
Post a Comment