-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmodels.py
More file actions
29 lines (22 loc) · 745 Bytes
/
models.py
File metadata and controls
29 lines (22 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from django.conf import settings
from django.db import models
# OneToOneField_tutorial
class Profile(models.Model):
user = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
primary_key=True
)
date_of_birth = models.DateField(blank=True, null=True)
def __str__(self):
return f'Profile for user {self.user.username}'
# custom related_name
# class Profile(models.Model):
# user = models.OneToOneField(
# settings.AUTH_USER_MODEL,
# on_delete=models.CASCADE,
# related_name="user_profile",
# )
# date_of_birth = models.DateField(blank=True, null=True)
# def __str__(self):
# return f'Profile for user {self.user.username}'