Untitled
unknown
plain_text
9 days ago
1.8 kB
1
Indexable
from email.policy import default from django.core.validators import MinLengthValidator, MaxLengthValidator, MinValueValidator from django.db import models # Create your models here. class DateTime(models.Model): class Meta: abstract = True created_at = models.DateTimeField( auto_now_add=True, ) class Label(DateTime): name = models.CharField( max_length=140, validators=[MinLengthValidator(2)] ) headquarters = models.CharField( max_length=150, default = 'Not specified', ) market_share = models.FloatField( validators=[MinLengthValidator(0.0), MinLengthValidator(100.0)], default=0.1 ) class Artist(DateTime): name = models.CharField( max_length=100, validators=[MinLengthValidator(2)] ) nationality = models.CharField( max_length=140, validators=[MinLengthValidator(2)] ) awards = models.PositiveIntegerField() class Album(DateTime): title = models.CharField( max_length=150, validators=[MinValueValidator(1)] ) release_date = models.DateField(null=True, blank=True) description = models.TextField(null=True, blank=True) TYPE_CHOICES = [ ('Single', 'Single'), ('Soundtrack', 'Soundtrack'), ('Remix', 'Remix'), ('Other', 'Other'), ] type = models.CharField( max_length=10, choices=TYPE_CHOICES, default='Other' ) is_hit = models.BooleanField(default=False) label = models.ForeignKey( Label, on_delete=models.SET_NULL, null=True, blank=True, related_name='albums' ) artist = models.ManyToManyField(Artist, related_name='albums')
Editor is loading...
Leave a Comment