def upload_video(request):
v = Video(video = request.FILES['videoFile'])
v.safe()
class Video(models.Model):
video = model.FileField(upload_to="/path/")
import os
import datetime
def user_directory_path(instance, filename):
# file will be uploaded to MEDIA_ROOT/user_<id>/<filename>
return os.path.join(
instance.user.name,
datetime.datetime.now().strftime('%Y_%m_%d__%H_%M'),
filename)
class MyModel(models.Model):
upload = models.FileField(upload_to=user_directory_path)