最近,我一直致力于一个项目,以使某些对我所参与的项目至关重要的任务变得容易多了。
我最后一次检查表格(一个月前)。从那时起,我将它从我的计算机上移到了服务器上。表格不再提交。
#forms.py
from django import forms
from .models import OnlineEssay, HardCopy, FaceToFaceConference
class OnlineEssayClientForm(forms.ModelForm):
class Meta:
model = OnlineEssay
fields = [
"client_first_name",
"client_last_name",
"client_grade",
"client_teacher",
"client_email",
"feedback_primary",
"feedback_secondary",
"essay_file",
]
labels = {
'client_first_name': ('First Name'),
'client_last_name': ('Last Name'),
'client_grade': ('Grade Level (As Number)'),
'client_teacher': ('Teacher'),
'client_email': ('Email Address'),
'feedback_primary': ('I need/would like feedback on:'),
'feedback_secondary': ('And,'),
}
class OnlineEssayTutorForm(forms.ModelForm):
class Meta:
model = OnlineEssay
fields = [
"essay_type",
"client_first_name",
"client_last_name",
"client_grade",
"client_teacher",
"client_email",
"feedback_primary",
"feedback_secondary",
"essay_file",
"essay_tutor",
"essay_feedback",
]
class HardCopyTutorForm(forms.ModelForm):
class Meta:
model = HardCopy
fields = [
"essay_type",
"client_first_name",
"client_last_name",
"client_grade",
"client_teacher",
"feedback_primary",
"feedback_secondary",
"essay_tutor",
"essay_feedback",
]
class FaceToFaceConferenceTutorForm(forms.ModelForm):
class Meta:
model = FaceToFaceConference
fields = [
"essay_type",
"client_first_name",
"client_last_name",
"client_grade",
"client_teacher",
"feedback_primary",
"feedback_secondary",
"essay_tutor",
"essay_feedback_notes",
]
<!-- templates/submit.html -->
{% extends 'base.html' %}
{% load crispy_forms_tags %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
{% block head_title %}Welcome{% endblock %}
</head>
<body>
{% block content %}
<h1>Submit Your Essay</h1>
<div class="bs-callout bs-callout-default">
<p>Fill Out The Form Below, then press Submit</p>
</div
<form method="post" enctype="multipart/form-data">{%csrf_token%}
{{form|crispy}}
<input class="btn btn-primary" type="submit" value="Submit" />
</form>
{% endblock %}
</body>
</html>
#views.py
from django.shortcuts import render
from django import http
# Create your views here.
from .forms import OnlineEssayClientForm
def submit(request):
form = OnlineEssayClientForm(request.POST or None, request.FILES or None)
context = {
"form": form,
"page_title" : "Submit Your Essay",
}
if form.is_valid():
form.save()
return http.HttpResponseRedirect('/success/')
return render(request, "submit.html", context)
答案 0 :(得分:0)
这实际上是一个非常简单的问题。我忘了在标注结束时关闭</div>
标记。表格现在提交。