确认后退按钮“Python with Django”的重新提交错误

时间:2018-04-18 23:31:52

标签: python django

我构建了一个Web应用程序,用户可以登录并查看工单,属性列表和外部承包商。但是,当我单击查看属性列表页面上的后退按钮或查看工作订单页面或查看外部承包商页面时,它会给出一个错误说明确认重新提交。 Error screenshot

def user_login(request):
if request.method == 'POST':
    form = LoginForm(request.POST)
    if form.is_valid():
        cd = form.cleaned_data
        user = authenticate(username=cd['username'], password=cd['password'])

        if user is not None:
            if user.is_active:
                login(request, user)
                if request.user.username == 'propertymanager':
                    #return HttpResponse('Authenticated successfully')
                    return render(request, 'account/dashboard.html', {'section': dashboard})
                elif request.user.username == 'technician1':
                    #return HttpResponse('Authenticated successfully')
                    return render(request, 'account/technician_dashboard.html', {'section': dashboard})
                elif request.user.username == 'technician2':
                    return render(request, 'account/technician2_dashboard.html',{'section': technician2_dashboard})
                else:
                    return render(request, 'registration/incorrect_user.html', {'section':incorrect_user})
            else:
                return HttpResponse('Disabled account')
        else:
            return render(request, 'registration/login.html', {'section': incorrect_login})
    else:
        return render(request, 'registration/login.html', {'section': incorrect_login})
else:
    form = LoginForm()
    return render(request, 'account/login.html', {'form': form})

我尝试用仪表板页面替换最后一个

                else:
                return HttpResponse('Disabled account')
        else:
            return render(request, 'registration/login.html', {'section': incorrect_login})
    else:
        return render(request, 'registration/login.html', {'section': incorrect_login})
else:
    return render(request, 'account/dashboard.html', {'section': dashboard})

但是现在我的登录按钮不起作用。 需要帮助!当我在查看属性列表页面并单击后退按钮时,我应该能够看到仪表板

1 个答案:

答案 0 :(得分:0)

每个列表都应该是自己的视图,而不仅仅是它自己的模板。

请阅读django docs tutorial并遵循其中提供的一般准则。