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+)$']
求大神分析下啥问题...
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/324160
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.