I'm making a website where the Auth.User is extended by a Userprofile where it has a foreign key to the User itself aswell as a key to user who invited the user.
I am using related_name for both but it throws me an error:
ERRORS:
<class 'account.admin.UserProfileInline'>: (admin.E202) 'account.UserProfile' has more than one ForeignKey to 'auth.User'.
Heres model:
class UserProfile(models.Model):
user = models.OneToOneField(User ,on_delete=models.CASCADE, related_name="user")
invited_by = models.OneToOneField(User, related_name="invited_by")
bought = models.ManyToManyField(product, blank=True)
def __str__(self):
return str(self.user)
Why does it still say that i have to many foreign keys? If i would change the name to a invalid related_name then it says that i need to add a correct one. I dont see my error...