Good day, friends!
I am trying to define a one-to-one relationship to an user in django admin. Below is my code in models.py in an app:
from django.db import models
class Tutor(models.Model):
account = models.OneToOneField([A User from Admin]) # what should I code here?
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200)
What should I write instead of [A User from Admin]?
Thanks.
Now if you want to access it by user info then you can. Say, you need to access a user's first_name. Then you will just run the relationship query here:
Additional information: If you need to add first_name and last_name for User you do not need to add another table. Just extends the UserCreationForm and add additional field for User Model.