开发者社区> 问答> 正文

Django (Python)中多次传递参数失败

我是刚接触django的。我目前的计划是显示用户名在不同的html页面,一旦用户成功登录。目前,登录后的页面可以成功地将带有django标记的用户名以html的形式显示为{{username}}。但是一旦它成功地传递到我的第二页,我的第二页就不能传递到第三页。附上的图片是我的html代码第二。html和第三。html。谢谢你的帮助。

 <form action="/SecondPageSub/" method="POST">
    {% csrf_token %}<br>
    <b>NTID:</b><br>
    <label name="usrnm">{{username}}</label>
    <button type="submit" name="SecondPageSub">
    SUBMIT
    </button>
</form>
     <form action="/ThirdPageSub/" method="POST">
        {% csrf_token %}<br>
        <b>NTID:</b><br>
        <label name="usrnm">{{username}}</label>
        <button type="submit" name="ThirdPageSub">
        SUBMIT
        </button>
    </form>
    def ActionGet(request):
        if request.method == "POST":
            if 'login' in request.POST:
                usrname = request.POST.get("usrnm", None)
                passwrd = request.POST.get("pwd", None)
                dic={}
                dic['username']=usrname
                dic['password']=passwrd
                return render(request, "Second.html",dic)

            if 'SecondPageSub' in request.POST:
                usrname = request.POST.get("usrnm", None)
                dic={}
                dic['username']=usrname
                return render(request, "Third.html",dic)

            if 'ThirdPageSub' in request.POST:
                usrname = request.POST.get("usrnm", None)
                dic={}
                dic['username']=usrname
                return render(request, "Forth.html",dic)

问题来源StackOverflow 地址:/questions/59466804/failure-in-multiple-times-parameters-passing-in-django-python

展开
收起
kun坤 2019-12-25 09:40:42 379 0
1 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载