我有一个显示可以使用提交按钮保存的表单的视图。我不希望在提交表单时重新加载视图。但是,如果函数不返回响应,我会遇到错误。
视图.py
from django.shortcuts import render_to_response
from ezmapping.models import *
from django.forms.models import modelformset_factory
def setAppOptions(request, map_name):
if request.user.is_authenticated():
app_selected = EzApp.objects.get(app_name=app_name, created_by=request.user)
formset = ezAppOptionFormSet(user=request.user, instance=app_selected)
if request.method == 'POST':
formset = ezAppOptionFormSet(request.POST, instance=app_selected, user=request.user)
if formset.is_valid():
formset.save()
return render_to_response("manage_app_options.html", {'formset': formset}, context_instance=RequestContext(request))
else:
error_msg = u"You are not logged in"
return HttpResponseServerError(error_msg)