SHARE
TWEET

Models.py za provjeru

a guest Dec 14th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.db import models
  2.  
  3. # Create your models here.
  4.  
  5. # You are to develop a simple media catalog functionality. All media in the catalog
  6. # has (at least) the following properties:
  7. # ● Media Title
  8. # ● Artist (Creator)
  9. # ● Publisher (Provider)
  10. # ● Originating Country
  11. # ● Genre (Category)
  12. # ● Publishing Date (different from when media was added to catalog)
  13. # ● “Usual” data modelling properties likeID, timestamps, user id creating/updating
  14.  
  15. # Media Catalog Administrator can search media items based on genre, category, etc.
  16. # Administrator then select desired media and assigned to either specific user,
  17. # group of users or make it available for all users.
  18. # When assigning media to users (publishing) the expiry date can be set by Admin.
  19.  
  20. class Creator(models.Model):
  21.     full_name           = models.CharField(max_length=50)
  22.     date_of_birth       = models.DateField(auto_now_add=False, auto_now=False)
  23.  
  24.     class Meta:
  25.         verbose_name = "Category"
  26.         verbose_name_plural = "Categories"
  27.  
  28.     def __str__(self):
  29.         return self.full_name
  30.  
  31.  
  32.  
  33. class Provider(models.Model):
  34.     provider_name       = models.CharField(max_length=30)
  35.  
  36.  
  37.     class Meta:
  38.         verbose_name = "Provider"
  39.         verbose_name_plural = "Providers"
  40.  
  41.     def __str__(self):
  42.         return self.provider_name
  43.  
  44.  
  45. class Category(models.Model):
  46.     category_name       = models.CharField(max_length=25)
  47.  
  48.  
  49.     class Meta:
  50.         verbose_name = "Category"
  51.         verbose_name_plural = "Categories"
  52.  
  53.     def __str__(self):
  54.         return self.category_name
  55.  
  56. class Media(models.Model):
  57.     title                   = models.CharField(max_length=120)
  58.     artist                  = models.ManyToManyField(Creator)
  59.     publisher               = models.ManyToManyField(Provider)
  60.     originating_country     = models.CharField(max_length=50)
  61.     genre                   = models.ManyToManyField(Category,)
  62.     publishing_date         = models.DateField(auto_now=False, auto_now_add=False)
  63.     date_published          = models.DateTimeField(auto_now_add=True)
  64.  
  65.     class Meta:
  66.         verbose_name = "Media"
  67.         verbose_name_plural = "Medias"
  68.  
  69.     def __str__(self):
  70.         return self.title
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top