我正在尝试使用模型类创建一个多步骤表单:
我的观点:
# this is my tz_create view
def makingx(request):
try:
#this is to check if user has filled info already before
dashprofile = DashboardProfile.objects.get(user=request.user)
#some view stuff
context = {
'user':user
}
return render_to_response(
'done.html',
context,
context_instance = RequestContext(request),
)
except DashboardProfile.DoesNotExist:
#some more stuff
if request.method == "POST":
if form.is_valid():
#more view stuff
request.session['created_busi'] = True
return HttpResponseRedirect(reverse('tx_create'))
else:
return render_to_response(
'd12.html',
{
'user':user},
context_instance = RequestContext(request)
)
我的tx_create视图:
def promocamp(request):
if 'created_info' not in request.session:
return HttpResponseRedirect(
reverse('tz_create')
)
user = request.user
if request.method == "POST":
if campaign.is_valid():
#some stuff
if 'next' in request.POST:
next = request.POST['next']
else:
next = reverse('busi_create')
return HttpResponseRedirect(next)
return render_to_response(
'd14.html',
{'CampaignForm':campaign,
'user':user},
context_instance = RequestContext(request)
)
步骤需要从tz到tx创建 但是tx_create似乎永远不会出现......我应该做什么/可能是什么错误?
答案 0 :(得分:0)
从您的代码中我看到return HttpResponseRedirect(reverse('tx_create'))
在三个条件下被调用:
确保满足所有这三个条件。在每个条件中使用一些调试输出来查看流程中断的位置。
答案 1 :(得分:0)
您在哪里设置session['created_info']
?
if 'created_info' not in request.session...
此外,您在哪里使用request.session['created_busi']
?