ex )
User : Profile
#django/contrib/auth/models.py
class User(abstractBaseUser):
...
#accounts/models.py
class Profile(models.Model):
author = models.OneToOneField(settings.AUTH_USER_MODEL , on_delete=models.CASCADE)
참고자료 :
https://docs.djangoproject.com/en/3.0/ref/models/fields/#onetoonefiled
In [4]: profile = Profile.objects.first()
In [5]: profile
Out[5]: <Profile: Profile object (1)>
In [6]: profile.user
Out[6]: <User: jakdu>
In [7]: from django.contrib.auth.models import User
In [8]: from django.contrib.auth import get_user_model
In [9]: User = get_user_model()
In [10]: user=User.objects.first()
In [11]: user.profile
Out[11]: <Profile: Profile object (1)>