http://127.0.0.1:8000/ i get this error:
http://127.0.0.1:8000/我得到这个错误:
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
urls.py
urls . 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')),
)
polls/urls.py
民意调查/ urls . 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
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')
templates/polls/index.html
模板/调查/ index . html
<html>
<head>
<title>page</title>
</head>
<body>
<p><a href="{% url 'name' %}">Hello</a></p>
</body>
</html>
1 个解决方案
#1
1
Remove the dollar sign from the inclusion url:
从包含url中删除美元符号:
url(r'^', include('polls.urls')),
#1
1
Remove the dollar sign from the inclusion url:
从包含url中删除美元符号:
url(r'^', include('polls.urls')),