0

エラーは、{% url product %}

NoReverseMatch at /category/

Reverse for '' with arguments '()' and keyword arguments '{}' not found.

Request Method: GET

    Request URL:    http://127.0.0.1:8000/category/

Django Version: 1.4

Exception Type: NoReverseMatch

Exception Value:    

Reverse for '' with arguments '()' and keyword arguments '{}' not found.

Exception Location: C:\Python27\lib\site-packages\django\template\defaulttags.py in render, line 424

Python Executable:  C:\Python27\python.exe

Python Version: 2.7.2

私のHTML

<html>
<body>
  <p> The list of items are </p>
  {% for items in allobs %}
    <li>{{items}}</li>
  {% endfor %}

  <p><a href="{% url product %}">Product list</a></p>
</body>
</html>

私の見解

from django.http import HttpResponse, Http404
from models import Category, Product
from datetime import datetime, timedelta, date, time
from django.shortcuts import render_to_response


def hello(request):
    return HttpResponse("Hello World")


def category(request):
    cat = Category.objects.all()    
    return render_to_response('category.html',{'allobs': cat})

def product(request):
    pro = Product.objects.all()
    return render_to_response('product.html',{'allobs':pro})

のURL

from django.conf.urls.defaults import *
from django.contrib import admin
from website.views import hello, category, product
from django.conf import settings


admin.autodiscover()

urlpatterns = patterns('',    
    url(r'^admin/', include(admin.site.urls)),
    url(r'^hello/$', hello),
    url(r'^category/$', category),
    (r'^tinymce/', include('tinymce.urls')),
    url(r'^product/$', product),   


)

if settings.DEBUG:
    urlpatterns += patterns('django.views.static',
        (r'images/(?P<path>.*)', 'serve', {'document_root': settings.MEDIA_ROOT}),       
    )
4

1 に答える 1