<0x7f440740dd70的功能详细信息>

2024-05-10 19:17:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我对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>

这个url映射到我的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.

这个函数是什么。感谢您的帮助!你知道吗


Tags: thedjangoidurlgeturlsmethodtr