django url电子邮件参数不起作用

时间:2014-03-02 21:47:49

标签: python django

我试图通过网址传递电子邮件,但我收到此错误:

  

当前网址fback / test@gmail.com/与这些网址中的任何一个都不匹配。

我的urls.py是:

from django.conf.urls import *

urlpatterns = patterns('fback.views',

url(r'^$', 'index', name='index'),
url(r'^fback/(?P<email>\t+)/$', 'vedi_dettagli', name='vedi'),
#url(r'^fback/dettagli', 'vedi_dettagli', name='vedialtro'),

)

views.py是:

def vedi_dettagli(request, email):
vedi = get_object_or_404(Societa, email='email')
response = render_to_response('fback/dettagli.html', RequestContext(request, locals()))
return response

任何人都可以看到错误吗?

1 个答案:

答案 0 :(得分:0)

尝试

url(r'^fback/(?P<email>\w+)/$', 'vedi_dettagli', name='vedi'),

也:

def vedi_dettagli(request, email):
    vedi = get_object_or_404(Societa, email=email) ####<< not 'email'
    response = render_to_response('fback/dettagli.html', RequestContext(request, locals()))
    return response