开发者

Why doesn't this django code work?

开发者 https://www.devze.com 2023-02-24 12:14 出处:网络
urls.py url(r\'^some/page/$\', views.some_page, {\'template_name\': \'some/page.html\'}, name=\'开发者_C百科some_page\'),

urls.py

url(r'^some/page/$', views.some_page,
    {'template_name': 'some/page.html'},
    name='开发者_C百科some_page'),

views.py

url = request.build_absolute_uri(reverse('some_page')).lower()
response = HttpResponseRedirect(url)
return response

Question: Why doesn't this code work?

url = request.build_absolute_uri(reverse('some_page', 
    kwargs={"template_name": "another/page.html"})).lower()

I'm using django 1.2 on google appengine. Since I get the same error for any kind of typo/mistake, I didn't think it was useful to paste that error message here.

Thanks.


Because reverse expects the arguments to “fill in” regular expressions in the url. So reverse('some_page') should work.

What do you expect it to do?

0

精彩评论

暂无评论...
验证码 换一张
取 消