Добавил поле "обложка" для модели Artist

This commit is contained in:
Viner Abubakirov
2026-01-02 15:31:32 +05:00
parent c36e236c3f
commit b8fc219f09
2 changed files with 30 additions and 0 deletions

View File

@@ -10,8 +10,14 @@ def album_cover_upload_to(instance, filename):
return os.path.join("album_covers", f"{uuid.uuid4()}.{ext}")
def artist_cover_upload_to(instance, filename):
ext = filename.split(".")[-1]
return os.path.join("artist_covers", f"{uuid.uuid4()}.{ext}")
class Artist(BaseModel):
name = models.CharField(max_length=200)
cover_image = models.ImageField(upload_to=artist_cover_upload_to, null=True, blank=True)
def __str__(self):
return f"{self.name}"