无法为Django视图配置url模式

时间:2014-04-01 13:05:19

标签: python django django-templates django-views

每当我向http://127.0.0.1:8000/contact/?id=23 got this error:

提出请求时
The current URL, contact/, didn't match any of these.

Views.py

def generate_data(request, contact):
    number = request.GET.get('contact', '')
    return str(resp)

url.py

url(r'^data/(?P<contact>\w+)$', 'myapp.views.generate_data', name='generating data'),

template没有views.py。我试图根据url pattern官方文档更改django,但没有成功。

1 个答案:

答案 0 :(得分:0)

尝试

url(r'^data/(?P<contact>\w+)/$', 'myapp.views.generate_data', name='generating data'),

并且您要求

> http://127.0.0.1:8000/data/< contact_id >