def contact(request):
if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
return HttpResponseRedirect('/thanks/') # Redirect after POST
else:
form = ContactForm() # An unbound form
return render_to_response('contact.html', {
'form': form,
})
이는 많은 조건문이며 ContactForm() 구조를 반복하며 모든 블록이 어디에서나 반복됩니다 보기는 양식을 처리해야합니다. 그것을하는 더 좋은 방법이 있습니까?
장고는 수년 전부터 일반 뷰를 보유하고 있습니다. 이 질문과 내가 보는 모든 대답은 구식입니다. 참조 : https://docs.djangoproject.com/ko/1.9/ref/class-based-views/generic-editing/ – guettli