请帮助这个新人!!!
我有两种不同的看法:
@login_required
@csrf_protect
def viewone(request):
#some code here...
if request.method == 'POST':
form = ViewOne(request.POST)
if form.is_valid():
try:
#some code here
return response
else:
form = ViewOne()
return render_to_response('templateone.html', { 'form': form, }, context_instance=RequestContext(request))
@login_required
@csrf_protect
def viewtwo(request):
if request.method == "GET":
#code here
return render_to_response('templatetwo.html', {'form1': MyForm(request.GET)}, context_instance=RequestContext(request))
else:
return render_to_response('templatetwo.html', {'form1': MyForm()}, context_instance=RequestContext(request))
我应该想知道如何将这些视图合并/渲染到同一个模板中,以便使用这两种功能!请帮助我遵循正确的方向!