text: from django.db import models
  
  import os
  from uuid import uuid4
  from django.utils.deconstruct import deconstructible
  
  # Create your models here.
  
  @deconstructible
  class PathAndRename(object):
  
      def __init__(self, sub_path):
              self.path = sub_path
  
      def __call__(self, instance, filename):
          ext = filename.split('.')[-1]
          # set filename as random string
          filename = '{}.{}'.format(uuid4().hex, ext)
          # return the whole path to the file
          return os.path.join(self.path, filename)
  
      def name(self, instance, filename):
          ext = filename.split('.')[-1]
          # set filename as random string
          filename = '{}.{}'.format(uuid4().hex, ext)
          # return the whole path to the file
          return filename
  
  class Stars(models.Model):
      name = models.CharField(max_length=124, unique=True)
  
      def __str__(self):
          return self.name
  
  class Photos(models.Model):    
      path_and_rename = PathAndRename("images/")
      
      image = models.ImageField(upload_to=path_and_rename)
  
      def __str__(self):
          return self.image.name
      
  class Movies(models.Model):
      path_and_rename = PathAndRename("poster/")
  
      # Nazwa, rok produkcji, miejsce produkcji, reżyser, scenariusz, premiera światowa, czas trwania, 5 głównych bohaterów, 100 znaków opis
      name = models.CharField(max_length=128)
      year_of_production = models.CharField(max_length=64)
      production_place = models.CharField(max_length=64)
      director = models.CharField(max_length=64)
      screenwriter = models.CharField(max_length=64)
      release_date = models.DateField()
      runtime = models.CharField(max_length=64)
      stars_list = models.ManyToManyField(Stars)
      poster = models.ImageField(upload_to=path_and_rename)
      photo_list = models.ManyToManyField(Photos)
      description = models.TextField(max_length=512)
  
      def __str__(self):
          return self.name