我有以下Django设置。
class Method1(models.Model):
inputfile_param = models.FileField()
species_param = models.CharField(max_length=20, choices=(('mouse', 'Mouse'), ('human','Human')))
norm_mode_param = models.CharField(max_length=20, choices=(('genecount_norm', 'Gene Count'), ('totalscore_norm','Total Score')))
logscale_param = models.BooleanField(default=False)
from .forms import Method1Form
def method1_input(request):
if request.method == 'POST':
form = Method1Form(request.POST, request.FILES)
# Handle file upload
if form.is_valid():
q = form.save()
q.save()
# This is where we run code
# with the given parameters
q.run_code1()
# This will show the method1_result to be executed.
return HttpResponseRedirect(reverse('method1-result', kwargs={'id': q.id }))
else:
form = Method1Form()
return render(request, 'mycool_app/method1.html', {'form':form})
from .models import Method1
class Method1Form(forms.ModelForm):
class Meta:
model = Method1
# Exclude means what not to show
# when form is displayed
exclude = ['state','clustering_state','ip_address','creationtime']
设置mycool_app/method1.html
文件:
<!DOCTYPE html>
<html>
<body>
<form action="{% url 'method1-input' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<p> {{form.inputfile_param.errors}} </p>
<p> {{form.inputfile_param}} </p>
<p> {{form.species_param }} </p>
<p> {{form.norm_mode_param }} </p>
<p> Log-scaling {{form.logscale_param}}</p>
<p><input type="submit" value="Upload" /></p>
</body>
</html>
最后它看起来像这样:
我想用Bootstrap渲染它。我该怎么办?
答案 0 :(得分:-1)