#!/usr/bin/env python3
Comments
db_table = 'article'
comments_article
article_title
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)