M
M
Maks Hate2017-04-11 11:23:25
Django
Maks Hate, 2017-04-11 11:23:25

How to add video to django blog?

Hello to all! Let me start off by saying that I am new to programming. I wrote in the FileField models and the paths where it should save them, but I didn’t understand what to write in views and templates (what tags to write) so that everything is displayed correctly on the site. Thanks to everyone in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yeldos Adetbekov, 2017-04-11
@4elive8

models.py:

from transliterate import translit

def upload_location(instance,filename):
  return "%s/%s" %('video',translit(filename,'ru',reversed=True))
...
class ClassName(models.Model):
        ...
        file = models.FileField(upload_to=upload_location,blank=True,null=True)
        ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question