需要帮助。我不知道代码行中的错误是什么。追溯指向form.save()行。
#views.py
class TestimonyFormFunction(View):
form = TestimonyForm
template = 'variablized_form.html'
@method_decorator(login_required)
def get(self, request):
form = self.form_class(None)
return render(request, self.template, {'form':form})
def post(self, request):
if request.method == 'POST':
form = TestimonyForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return render(request, 'testimony_post.html', {'Testimony':Testimony})
else:
form = TestimonyForm()
return render(request, 'variablized_form.html', {'form': form})
#forms.py
class TestimonyForm(forms.Form):
body = forms.CharField(label='Details', widget=forms.Textarea)