【发布时间】:2014-11-12 18:49:28
【问题描述】:
当加载一个页面时,我希望用户被直接发送到它的一部分,称为#town-center。
我写了以下代码:
url(r'^(?i)(?P<town_slug>[-\w]+)/', RedirectView.as_view(permanent=False, url='#town-center')), # adds the "town-center" anchor to reposition the browser when displaying the town
url(r'^(?i)(?P<town_slug>[-\w]+)/#$', views.town_map, name='town_map'),
这适用于将#town-center 添加到当前 URL,但它失败了,因为第一个模式总是被拾取,并且它循环。
我从 Firefox 得到的确切错误是:“页面没有正确重定向”。
我怎样才能做到这一点?
【问题讨论】:
标签: regex django anchor django-urls