A
A
altertable2020-05-02 22:26:58
Django
altertable, 2020-05-02 22:26:58

Why, when adding an image to the database through the admin panel, create two media folders ???

in settings.py

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


models.py
class Film(models.Model): # Фильм 
    name = models.CharField(max_length = 150)
    duration_film = models.TimeField() # '14:30'
    desc = models.TextField()
    year = models.PositiveSmallIntegerField("Дата выхода", default=2019)
    contry = models.CharField(max_length = 150)
    genre = models.ManyToManyField(Genre, verbose_name="жанры")
    actor = models.ManyToManyField(Actor, verbose_name="актеры", related_name="film_actor")
    directors = models.ManyToManyField(Actor, verbose_name="режиссер", related_name="film_director")
    premiere = models.CharField(max_length = 150)
    budget = models.PositiveIntegerField()
    image = models.ImageField(upload_to = 'media/posters/')
    def __str__(self):
        return self.name


5eadca4d253f5875187564.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alternativshik, 2020-05-03
@vityareabko

upload_to = 'media/posters/' don't need media/ here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question