【发布时间】:2014-11-08 07:15:30
【问题描述】:
我在 Django 中有一个简单的模型:
class Test(models.Model):
user = models.ForeignKey(User, null=True, blank=True)
title = models.CharField(max_length=180, unique=True)
file1 = models.FileField(upload_to=download_loc)
preview = models.FileField(upload_to=preview_loc)
file1 是一个文件,我在客户端动态生成 file1(jpg 图像)的“预览”。
我正在尝试将它们中的两个上传到同一个表单上,但我找不到一个简单的方法来做到这一点。 我怎么能用 Jquery 做到这一点?
这是我所拥有的表单的类:
class TestForm(ModelForm):
class Meta:
model = Test
fields = ('title', 'file1') # I don't want to put preview here because it should be done without the user intervention (I don't want the user to see a button with choose file for the preview)
非常感谢!
【问题讨论】:
标签: jquery django file-upload