Advertisement
horozov86

Exam Prep 1 Database

Dec 8th, 2023
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.64 KB | None | 0 0
  1. # 1.    Database – 100 points
  2.  
  3. class Director(models.Model):
  4.     full_name = models.CharField(max_length=120, validators=[MinLengthValidatior(2)])
  5.     birth_date = models.DateField(default='1900-01-01')
  6.     nationality = models.CharField(max_length=50, default='Unknown')
  7.     years_of_experience = models.SmallIntegerField(default=0, validators=[MinValueValidator(0)])
  8.    
  9. class Actor(models.Model):
  10.     full_name = models.CharField(max_length=120, validators=[MinLengthValidatior(2)])
  11.     birth_date = models.DateField(default='1900-01-01')
  12.     nationality = models.CharField(max_length=50, default='Unknown')
  13.     is_awarded = models.BooleanField(default=False)
  14.     last_updated = models.DateTimeField(auto_now=True)
  15.  
  16. class Movie(models.Model):
  17.     GENRE_CHOICES = (
  18.         ('Action', 'Action'),
  19.         ('Comedy', 'Comedy'),
  20.         ('Drama', 'Drama'),
  21.         ('Other', 'Other')
  22.         )
  23.     title = models.CharField(max_length=150, validatiors=[MinLengthValidatior(5)])
  24.     release_date = models.DateField()
  25.     storyline = models.TextField(null=True, blank=True)
  26.     genre = models.CharField(max_length=6, default='Other')
  27.     rating = models.DecimalField(max_digits=3, decimal_places=1, validators=[validators.MinValueValidator(0), validators.MaxValueValidator(10)], default=0)
  28.     is_classic = models.BooleanField(default=False)
  29.     is_awarded = models.BooleanField(default=False)
  30.     last_updated = models.DateTimeField(auto_now=True)
  31.     director = models.ForeignKey("Director", on_delete=models.CASCADE)
  32.     starring_actor = models.ForeignKey("Actor", null=True, on_delete=models.SET_NULL)
  33.     actors = models.ManyToManyField("Actor")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement