forked from reactive-python/reactpy-django
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
23 lines (15 loc) · 842 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from django.db import models
class TodoItem(models.Model):
done = models.BooleanField() # type: ignore
text = models.CharField(max_length=1000) # type: ignore
class RelationalChild(models.Model):
text = models.CharField(max_length=1000) # type: ignore
class RelationalParent(models.Model):
done = models.BooleanField(default=True) # type: ignore
many_to_many = models.ManyToManyField(RelationalChild, related_name="many_to_many") # type: ignore
one_to_one = models.OneToOneField( # type: ignore
RelationalChild, related_name="one_to_one", on_delete=models.SET_NULL, null=True
)
class ForiegnChild(models.Model):
text = models.CharField(max_length=1000) # type: ignore
parent = models.ForeignKey(RelationalParent, related_name="many_to_one", on_delete=models.CASCADE) # type: ignore