我的urlconf
from django.conf.urls import patterns, include, url
from django.conf import settings
urlpatterns = patterns('app.views',
url(r'^$', TemplateView.as_view(template_name='apps/index.html'),
name='index'),
url(r'^product/list/$','list_of_products' ,name='list_p'),
url(r'^product/(?P<product_id>\d+)/$','product_detail' ,name='list_detail'),
url(r'^order/(?P<order_id>\d+)/$','order_detail' ,name='order_detail'),
url(r'^order/list/$','list_of_orders' ,name='list_orders'),
)
所以,当我在下面的浏览器中尝试上述网址时
localhost:8000/product/list/
localhost:8000/product/4/
是的,它的工作正常,但当我在下面尝试上面的网址without forward slash
时
localhost:8000/product/list
localhost:8000/product/4
我找不到下面的页面
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/product/list
Using the URLconf defined in urlconf, Django tried these URL patterns, in this
.......
........
实际上为什么它会发生,在一般情况下,即使我们没有给出正斜杠,它应该重定向到所需的URL?
所以任何人都可以告诉我如何避免这种情况,并且我在定义urlconf时做错了什么?