V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Yuanhan
V2EX  ›  Python

Django 获取当前的 URL

  •  
  •   Yuanhan · 2015-06-16 15:15:18 +08:00 · 2441 次点击
    这是一个创建于 3248 天前的主题,其中的信息可能已经有所发展或是发生改变。

    由于URL后带有参数,每次都不同。
    想要动态获取URL,不知道Django如何实现。
    本人是一名初学者,相通过学习Django来了解Python,希望诸位指点。
    网址示例: http://a.b.com/?from=xx&yy=0

    3 条回复
    jruif
        1
    jruif  
       2015-06-16 15:33:48 +08:00
    问好后面是查询字段,看文档你就懂了: https://docs.djangoproject.com/en/1.8/ref/request-response/
    Yuanhan
        2
    Yuanhan  
    OP
       2015-06-16 17:28:30 +08:00
    @jruif 十分感谢您的赐教,我读了您发的文档,觉得request.get_full_path()应该是我所需。
    恕我愚钝,产生各种报错。能否浪费你点时间,写个用法示例,小弟感激不尽
    mugbya
        3
    mugbya  
       2015-06-17 16:30:21 +08:00
    看这个吧 [How can I build multiple submit buttons django form?](http://stackoverflow.com/questions/866272/how-can-i-build-multiple-submit-buttons-django-form)

    一样原理
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3048 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:31 · PVG 23:31 · LAX 08:31 · JFK 11:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.