Commit 3fa5116b authored by Roman Desyatskii's avatar Roman Desyatskii

Models

parent efa15ccc
# from uuid import uuid4
# from tortoise import fields, models
#
#
# class IdMixin(models.Model):
# id = fields.UUIDField(pk=True, default=uuid4)
#
# class Meta:
# abstract = True
#
#
# class TimestampMixin(models.Model):
# created_at = fields.DatetimeField(auto_now_add=True)
# deleted_at = fields.DatetimeField(auto_now=True)
#
# class Meta:
# abstract = True
#
#
# class BaseModel(IdMixin, TimestampMixin):
#
# class Meta:
# ordering = ('-created_at', )
\ No newline at end of file
from tortoise import fields, models
class Genre(models.Model):
id = fields.IntField(pk=True)
name = fields.CharField(max_length=255, unique=True)
description = fields.TextField(null=True)
def __str__(self) -> str:
return self.name
\ No newline at end of file
from tortoise import models, fields
class Article(models.Model):
id = fields.IntField(pk=True)
name = fields.TextField()
def __str__(self) -> str:
return self.name
from tortoise import fields, models
class Person(models.Model):
id = fields.IntField(pk=True)
name = fields.CharField(max_length=255, null=True)
birth_date = fields.DateField(null=True)
def __str__(self):
return self.name
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment