urls.py 这么写的
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^$',views.home, name="home"),
url(r'^page/(\d+)$', views.home_page,name="home_page"),
url(r'^/tab/(\d+)/(\d+)$', views.category,name="category"),
url(r'^t/(\d+)$', views.article,name="article"),
url(r'^s/$', views.search,name="search"),
]
views.py 里面:
def category(request,cid,pid):
try:
cname = Category.objects.get(id=cid).name
posts = Posts.objects.filter(category=cid)
except Exception:
pass
return render(request, "blog/category.html",locals())
我一访问首页报错
NoReverseMatch at /
Reverse for 'category' with arguments '(2L,)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['/tab/(\\d+)/1|(\\d+)$']
求大神分析下啥问题...