<function details =“”at =“”0x7f440740dd70 =“”>

时间:2017-01-01 08:09:36

标签: python django

python和django编程有点新鲜,有人可以帮我理解这里发生了什么 我正在创建一个小型民意调查应用程序,这就是我所拥有的

在我的模板details.html

 <table>
      <tr><td><a href="/polls/{{ que.id }}/up"><i class="fa fa-chevron-up"></i> </a></td></tr>
      <tr><td><a href="/polls/{{ que.id }}/up"><i class="fa fa-chevron-down"></i></a></td></tr>
</table>

该网址在我的urls.py文件中映射到此

from django.conf.urls import url
from .import views

urlpatterns=[
     url(r'(?P<question_id>[a-z0-9A-Z]+)/(?P<method>[a-z]+)/$', views.like')

然后这是我的views.py

def like(request, question_id, method):
    #get the question
    question = Questions.objects(id=question_id).get()
    #get the method type
    if method == 'up':
        question.likes + 1
    elif method == 'down':
        question.likes - 1
    else:
        #handle the other invalid methods

但点击链接后我收到此错误

Page not found (404)    
Request Method:     GET
 Request URL:   http://127.0.0.1:8000/polls/586748a8d6ca3f1b30ee4ff9/up/%3Cfunction%20details%20at%200x7f440740dd70%3E

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
    1. ^admin/ 
    2. ^polls/ ^(?P<question_id>[a-z0-9A-Z]+)/(?P<method>[a-z]+)/$ 

The current URL, polls/586748a8d6ca3f1b30ee4ff9/up/<function details at 0x7f440740dd70>, didn't match any of these.

那么这个功能是什么呢。任何帮助表示赞赏!

0 个答案:

没有答案