Задать вопрос

Тел: +7 965 3737 888

459

Просмотров

0

Ответов

slug filename

<p>A one-liner that I use all the time: Set upload_to to something based on the slug and the filename's extension.
</p>
<p>Just add this function to the top of your models and use it like this:
       image = models.FileField(upload_to=slug_filename('people'))
</p>
<p>and the upload_to path will end up like this for eg myfile.jpg:
       people/this-is-the-slug.jpg
</p>
<p>Enjoy!
</p>

Вопрос полезен? Да0/Нет0
file_3901.py(503.0б)
None