【问题标题】:processing urls with hashes like jsbin使用 jsbin 等哈希处理 url
【发布时间】:2013-05-08 23:20:45
【问题描述】:

jsbin,在不支持(window.history && window.history.pushState)的浏览器上通过window.location.hash = data.edit;details here)修改url。

这会创建这样的网址

http://jsbin.com/#/imetor/1/edit

如何让 django 的 urls.py 处理这样的 url? I am not even sure that the hash is being sent to the server。如果它没有被发送到服务器,那么 jsbin 使用什么技术将这些参数传递给服务器?

FWIW,这不起作用:

url(r'^#/(?P<project_id>[0-9A-Za-z]{6,})', 'mysite.views.project_hash', name='project_hash'),

【问题讨论】:

    标签: python regex django url django-urls


    【解决方案1】:

    你是对的。 # 之后的部分不会发送到服务器。

    在django中,如果你想看到发送到服务器的url,你可以这样做

    print request.get_full_path()
    

    在 jsbin 的情况下,服务器返回一个包含 javascript 代码的页面,然后读取 url 参数并执行代码来个性化页面。解析 url 并执行函数的 javascript 代码示例是 Backbone.Router (http://backbonejs.org/#Router)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-19
      • 2011-05-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多