错误是:
Page not found (404)
Request Method: GET
Request URL: 'http://127.0.0.1:8000/admin/'
Using the URLconf defined in orangeowl.urls, Django tried these URL patterns, in this order:
^product/$
^product/(?P<slug>[-\w]+)/$
The current URL, admin/, didn't match any of these.
网址.py
from django.conf.urls import patterns, include, url
from django.conf.urls.defaults import *
from django.contrib import admin
from website.models import Product
from website.views import index
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/', admin.site.urls), #Lets us access the admin page
(r'^$', 'orangeowl.website.views.index'),
)
urlpatterns = patterns('django.views.generic.list_detail',
url(r'^product/$', 'object_list',
{'queryset': Product.objects.all()}),
url(r'^product/(?P<slug>[-\w]+)/$', 'object_detail',
{'queryset': Product.objects.all()})
)
视图.py
from models import Catalog
from models import Product
from models import CatalogCategory
from models import ProductAttribute
from models import ProductDetail
from django.http import HttpResponse
from django.shortcuts import render_to_response
def index(request): #Define our function, accept a request
catalog = Catalog.objects.all()
catalogcategory = CatalogCategory.objects.all()
product = Product.objects.all()
productattribute = ProductAttribute.objects.all()
productdetail = ProductDetail.objects.all()
return render_to_response('index.html', {'catalog': catalog}, {'product':product})
return render_to_response('product_detail.html', {'productdetail': productdetail})
return render_to_response('product_list.html', {'productattribute': productattribute})
设置.py
ROOT_URL_CONF = project.urls
INSTALLED_APPS = project.appname