DjangoModel FileField显示文件名

model

class Scene(models.Model):
	... ...
	writeup = models.FileField(verbose_name=u"场景解答手册", upload_to=uploadpath)
def uploadpath(instance, filename):
    # MEDIA_ROOT/<model_name>_<uuid4>.<fileext>
    return '{0}_{1}{2}'.format(instance._meta.model_name, str(uuid.uuid4()),
                               '.pdf')
posted @ 2021-02-01 16:07  久末丶  阅读(323)  评论(0编辑  收藏  举报