1class Person(models.Model):
2 name = models.CharField(max_length=50)
3 birthday = models.DateField()
4 anniversary = models.ForeignKey(Anniversary, on_delete=models.CASCADE)
5 address = models.ForeignKey(Address, on_delete=models.DO_NOTHING)
6
7class Address(models.Model):
8 line1 = models.CharField(max_length=150)
9 line2 = models.CharField(max_length=150)
10 postalcode = models.CharField(max_length=10)
11 city = models.CharField(max_length=150)
12 country = models.CharField(max_length=150)
13
14class Anniversary(models.Model):
15 date = models.DateField()
16
1### Specify `fk_id` ###
2
3# Create
4employee = Employee.objects.create(
5 first_name='first',
6 last_name='last',
7 type_id=4,
8)
9
10# Edit
11employee = Employee(first_name="Name", last_name="Name")
12employee.type_id = 4
13employee.save()