我正在使用slugify来取一所大学的名字并将它们变成slu ..然后我将它们放在url路径中,但它返回page not found error
以下是我的网址。
项目网址:
from django.conf.urls import url
from django.contrib import admin
from django.conf.urls import include
#from ads import views
#from spider import views
#from stats import views
from listings import views
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$',views.HomeView.as_view(),name='index'),
# url(r'^ads/',include('ads.urls',namespace='ads')),
url(r'^university/',include('listings.urls',namespace='listings')),
# url(r'^spider/',include('spider.urls',namespace='spider')),
# url(r'^stats/',include('stats.urls',namespace='stats')),
]
app urls:
from django.conf.urls import url
from listings import views
app_name = 'listings'
urlpatterns = [
url(r'^(?P<u_slug>\w+)$',views.UniversityView.as_view(),name='university_homepage'),
url(r'^(?P<university>\w+)/(?P<u_slug>\w+)$',views.ListingView.as_view(),name='listing_detail'),
]
这是404:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/university/temple-university
一切看起来都不错,但我也一直在看这个,所以我可能会忽略一些东西。
答案 0 :(得分:1)
您的正则表达式模式匹配器仅匹配单词字符,并且与create
不匹配
更改
AdminsController
到
-