Добавил поле "обложка" для модели Artist
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 6.0 on 2026-01-02 10:30
|
||||||
|
|
||||||
|
import music.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('music', '0006_album_cover_image'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='artist',
|
||||||
|
name='cover_image',
|
||||||
|
field=models.ImageField(blank=True, null=True, upload_to=music.models.artist_cover_upload_to),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='album',
|
||||||
|
name='cover_image',
|
||||||
|
field=models.ImageField(blank=True, null=True, upload_to=music.models.album_cover_upload_to),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -10,8 +10,14 @@ def album_cover_upload_to(instance, filename):
|
|||||||
return os.path.join("album_covers", f"{uuid.uuid4()}.{ext}")
|
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):
|
class Artist(BaseModel):
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
|
cover_image = models.ImageField(upload_to=artist_cover_upload_to, null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.name}"
|
return f"{self.name}"
|
||||||
|
|||||||
Reference in New Issue
Block a user