django - Error: Reverse for 'detail' not found. 'detail' is not a valid view function or pattern name -
django version: 1.11.4 python: 3.6.1
i want add line html file:
<a class="pure-button" href="{% url 'detail' id=post.id %}">read more </a>
views.py:
def detail(request, id): try: post = article.objects.get(id=int(id)) except article.doesnotexist: raise http404 return render(request, 'post.html', {'post':post})
url.py:
django.conf.urls import url,include django.contrib import admin import article.views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^(\d+)', article.views.detail), url(r'^', article.views.home), ]
i met following errors:
noreversematch @ / reverse 'detail' not found. 'detail' not valid view function or pattern name. request method: request url: http://localhost:8000/ django version: 1.11.4 exception type: noreversematch exception value: reverse 'detail' not found. 'detail' not valid view function or pattern name.
who can me? many thanks!
url(r'^(?p<id>\d+)/$', article.views.detail, name='detail'),
change url of details view upper one
Comments
Post a Comment