嗨,我在 django 中使用以下 URL 模式,我想知道问题出在哪里以及为什么找不到它。以下屏幕截图显示了我的 URL 以及预期的 URL。
请告诉我哪里出错了。请告诉我是否可以告诉其他事情来理解问题。我看了将近一两个小时,然后我把它贴在 stackoverflow.com 上,希望我能得到一些解决方案。
在此处添加 urls.py:
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'ecomstore.views.home', name='home'),
#url(r'^catalog/', 'preview.views.home'),
# url(r'^ecomstore/', include('ecomstore.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
url(r'',include('catalog.urls')),
)
然后是目录应用程序的 urls.py:
from django.conf.urls.defaults import *
urlpatterns=patterns('catalog.views',
(r'^$','index',{'template_name':'catalog/index.html'},'catalog_home'),
(r'^category/(?P<category_slug>[-\w]+)/$','show_category',{'template_name':'catalog/category.html'},'catalog_category'),
(r'^product/(?P<product_slug>[-_\w+])/$','show_product',{'template_name':'catalog/product.html'},'catalog_product'),
)
提前谢谢你们。