Skip to content

Commit 5fbeae7

Browse files
authored
docs: update readme (#1957)
* docs: update readme * chore: upgrade deps
1 parent 3ecf32f commit 5fbeae7

File tree

2 files changed

+1425
-1272
lines changed

2 files changed

+1425
-1272
lines changed

README.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,19 @@ Define the models by inheriting from ``tortoise.models.Model``.
9898
9999
class Tournament(Model):
100100
id = fields.IntField(primary_key=True)
101-
name = fields.TextField()
101+
name = fields.CharField(max_length=20)
102102
103103
104104
class Event(Model):
105-
id = fields.IntField(primary_key=True)
105+
id = fields.BigIntField(primary_key=True)
106106
name = fields.TextField()
107-
tournament = fields.ForeignKeyField('models.Tournament', related_name='events')
108-
participants = fields.ManyToManyField('models.Team', related_name='events', through='event_team')
107+
tournament = fields.ForeignKeyField('models.Tournament', related_name='events', on_delete=fields.OnDelete.CASCADE)
108+
participants = fields.ManyToManyField('models.Team', related_name='events', through='event_team', on_delete=fields.OnDelete.SET_NULL)
109109
110110
111111
class Team(Model):
112-
id = fields.IntField(primary_key=True)
113-
name = fields.TextField()
112+
id = fields.UUIDField(primary_key=True)
113+
name = fields.CharField(max_length=20, unique=True)
114114
115115
116116
After defining the models, Tortoise ORM needs to be initialized to establish the relationships between models and connect to the database.

0 commit comments

Comments
 (0)