Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django:NoReverseMatch at/-->;与#x27相反;名称';带参数';()';和关键字参数';{}';没有找到。已尝试1个模式:[';$name/';]_Python_Django_Reverse - Fatal编程技术网

Python Django:NoReverseMatch at/-->;与#x27相反;名称';带参数';()';和关键字参数';{}';没有找到。已尝试1个模式:[';$name/';]

Python Django:NoReverseMatch at/-->;与#x27相反;名称';带参数';()';和关键字参数';{}';没有找到。已尝试1个模式:[';$name/';],python,django,reverse,Python,Django,Reverse,我得到这个错误: NoReverseMatch at / Reverse for 'name' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['$name/'] Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.7.5 Exception Type: No

我得到这个错误:

NoReverseMatch at /
Reverse for 'name' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['$name/']

Request Method:     GET

Request URL:    http://127.0.0.1:8000/
Django Version:     1.7.5
Exception Type:     NoReverseMatch
Exception Value:    Reverse for 'name' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['$name/']

Exception Location:     /usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 468

url.py

from django.conf.urls import patterns, include, url
from django.contrib import admin

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'mydjapp.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', include('polls.urls')),
)
轮询/url.py

from django.conf.urls import url, patterns
from django.shortcuts import render
from polls import views

urlpatterns = patterns('',
    url(r'^$', views.index, name='index'),
    url(r'^name/', views.name, name='name'),
)
views.py

from django.shortcuts import render

# Create your views here.

def index(request):
    return render(request, 'polls/index.html')

def name(request):
    return render(request, 'polls/index.html')
模板/polls/index.html

<html>
    <head>
        <title>page</title>
    </head>
    <body>
        <p><a href="{% url 'name' %}">Hello</a></p>
    </body>
</html>


从包含url中删除美元符号:

url(r'^', include('polls.urls')),