我对django很陌生,我现在正在创建我在数据库中上传数据的表单。我用的是django 1.10和python 2.7
我有一个upload.html在我的模板。然后i
<div class="form">]
<form method="post" action="{% url 'upload' %}" enctype=multipart/form-data >
{% csrf_token %}
<!-- This line inserts a CSRF token. -->
<table>
{{ form.as_table }}
<!-- This line displays lines of the form. -->
</table>
<p><input type="submit" value="Create" /></p>
</form>
</div>
A part of my forms.py
class Form_inscription(forms.Form):
study = forms.ModelChoiceField(label="Choose the study of the database file", queryset=Study.objects.all(),
initial=Study.objects.all()[:1].get().id)
databasefile = forms.FileField(label="Database file")
assay = forms.ModelChoiceField(label="Choose the assay", queryset=LookUpAssay.objects.all(),
initial=LookUpAssay.objects.all()[:1].get().id)
readout = forms.ChoiceField(label="Choose the readout, choose --- if assay contains all readouts", choices=readouttuple)
rawdatafile = forms.FileField(label ="Choose the raw data file")
然后用方括号显示。我也不知道为什么。
)
选择学习的数据库文件:
数据库文件:
选择化验:
选择读数,如果化验包含所有读数,选择——
选择原始数据文件:
不是你的表单,而是你的html。这里有一个方括号:
<div class="form">]
# ^