phase3: add normalized domain schema, admin, services, and multistage docker build
This commit is contained in:
33
apps/teams/models.py
Normal file
33
apps/teams/models.py
Normal file
@ -0,0 +1,33 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Team(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
short_name = models.CharField(max_length=80, blank=True)
|
||||
slug = models.SlugField(max_length=220, unique=True)
|
||||
country = models.ForeignKey(
|
||||
"players.Nationality",
|
||||
on_delete=models.SET_NULL,
|
||||
blank=True,
|
||||
null=True,
|
||||
related_name="teams",
|
||||
)
|
||||
founded_year = models.PositiveSmallIntegerField(blank=True, null=True)
|
||||
is_national_team = models.BooleanField(default=False)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["name", "country"], name="uq_team_name_country")
|
||||
]
|
||||
indexes = [
|
||||
models.Index(fields=["name"]),
|
||||
models.Index(fields=["slug"]),
|
||||
models.Index(fields=["country"]),
|
||||
models.Index(fields=["is_national_team"]),
|
||||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
Reference in New Issue
Block a user