zoukankan      html  css  js  c++  java
  • why request.path return None?

       in django, sometimes you want to pass value of current page path , you will do this follows:

      a. <form action="./?next={{request.path}}" method="post">...</form>

      b.<form action="" method="post">

       <input type="hidden" name="next" value="{{request.path}}"/>

       </form>

      c.<a href="xxx/?next={{request.path}}">xx</a>

      however, perheps you find out that the value of 'next' is None in views.py. so you could think that request is None. But my code is that:

    def index(request):
        xxxx
        return render_to_response('index.html',{},RequestContext(request))

      through my test. if you should apparently pass request, it will work ok. now the modified code is as follow:

    def index(request):
        xxxx
        return render_to_response('index.html',{'request':request},RequestContext(request))

      and i don't know why. if anyone konws,pleasure tell me the answer.



  • 相关阅读:
    用价值链分析软件开发及杂感
    《恰如其分的软件架构》笔记摘要
    观察者模式
    Js中Date对象
    Js中Currying的应用
    read命令
    模板方法模式
    两两交换链表中的节点
    享元模式
    Js中Array对象
  • 原文地址:https://www.cnblogs.com/slider/p/2980992.html
Copyright © 2011-2022 走看看