How to generate the path to save the file dynamically by DJANGO?

Here is the code
def upload_video(request):

 v = Video(video = request.FILES['videoFile'])

class Video(models.Model):
 video = model.FileField(upload_to="/path/")

The problem is that the path to save the file has to be generated dynamically, how can I do this
June 27th 19 at 15:00
1 answer
June 27th 19 at 15:02
At least there is


import os
import datetime

def user_directory_path(instance, filename):
 # file will be uploaded to MEDIA_ROOT/user_<id>/<filename>
 return os.path.join('%Y_%m_%d__%H_%M'), 

class MyModel(models.Model):
 upload = models.FileField(upload_to=user_directory_path)</filename></id>
This article was already read but still do not understand,can more chewed level translate?Senko) - Jany_Von commented on June 27th 19 at 15:05
: there's also the example shows how an id of the user journey to make, by analogy, and my wishlist add. - Garnett_Deckow commented on June 27th 19 at 15:08
All thanks,understood - Jany_Von commented on June 27th 19 at 15:11

Find more questions by tags DjangoPython