python - Django: NoReverseMatch at / --> Reverse for 'name' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['$name/'] -
python - Django: NoReverseMatch at / --> Reverse for 'name' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['$name/'] -
http://127.0.0.1:8000/ error:
noreversematch @ / reverse 'name' arguments '()' , keyword arguments '{}' not found. 1 pattern(s) tried: ['$name/'] request method: request url: http://127.0.0.1:8000/ django version: 1.7.5 exception type: noreversematch exception value: reverse 'name' arguments '()' , 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
from django.conf.urls import patterns, include, url 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
from django.conf.urls import url, patterns django.shortcuts import render 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 views here. def index(request): homecoming render(request, 'polls/index.html') def name(request): homecoming render(request, 'polls/index.html')
templates/polls/index.html
<html> <head> <title>page</title> </head> <body> <p><a href="{% url 'name' %}">hello</a></p> </body> </html>
remove dollar sign inclusion url:
url(r'^', include('polls.urls')),
python django reverse
Comments
Post a Comment