Answer the question
In order to leave comments, you need to log in
How to write code correctly?
class VideoDoc(models.Model):
name_video = models.CharField("Название", max_length=150, null=True, blank=True)
poster = models.ImageField("изображение", upload_to = 'product/videos/posters/', null=True, blank=True)
video = models.FileField("Видео", upload_to = "product/videos/", null=True, blank=True)
name_doc = models.CharField("Название", max_length=150, null=True, blank=True)
files = models.FileField("Документы", upload_to = "product/documents/", null=True, blank=True)
video_accept = models.BooleanField("Это видео")
doc_accept = models.BooleanField("Это документ")
doc_format = models.ForeignKey(Format, verbose_name='Формат файла', on_delete=models.DO_NOTHING)
"""function for demo visit"""
pdf = VideoDoc()
def demo():
filename, file_extension = os.path.splitext(pdf.files)
if file_extension == ".docx":
pass
elif file_extension == ".pdf":
images = convert_from_path(pdf.files, fmt="png")
else:
pass
return images
class Demo(models.Model):
demo_img = models.ImageField("Демо изображение", upload_to="product/documents/demo/", default=demo())
def __str__(self):
return f'{self.demo_img} - {self.VideoDoc().name_doc}'
class Meta:
verbose_name = 'Демо просмотр'
verbose_name_plural = "Демо просмотр"
class Demo_docx(models.Model):
demo_img = models.ImageField("Демо изображение", upload_to="product/documents/demo_doc/")
def __str__(self):
return f'{self.demo_img} - {self.VideoDoc().name_doc}'
class Meta:
verbose_name = 'Демо для док файлов'
verbose_name_plural = "Демо для док файлов"
demo_doc = models.ManyToManyField(Demo, verbose_name='Демо', null=True, blank=True)
demoForDoc = models.ManyToManyField(Demo_docx, verbose_name="Демо для док файлов", null=True, blank=True)
def __str__(self):
return f'{self.name_video} - {self.name_doc}'
class Meta:
verbose_name = 'Видео и документ'
verbose_name_plural = "Видео и документы"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question