eqy.fr/photos/models.py

15 lines
430 B
Python
Raw Permalink Normal View History

2023-12-20 08:32:47 +00:00
from django.db import models
class Media(models.Model):
2023-12-20 16:20:37 +00:00
title = models.CharField(max_length=500)
2023-12-20 08:32:47 +00:00
photo = models.FileField(upload_to="photos/%Y/", null=True, blank=True)
video = models.FileField(upload_to="videos/%Y/", null=True, blank=True)
def __str__(self):
if self.photo:
return self.photo.name
elif self.video:
return self.video.name
return super().__str__()