1,url路径传传参
html代码:<a href="{{ blog.id }}">
url代码:url(r'^blog/',include('blog.urls',namespace='blog'))
url(r'(?P<article_id>\d)/$',views.blog_article,name='blog_detail')
url(r'^article-detail/(?P<id>\d+)/(?P<slug>[-\w]+)/$', views.article_detail, name='article_detail'), 传输文字
后端代码:def blog_article(request,article_id):
# article = BlogArticle.objects.get(id=article_id)
article = get_object_or_404(BlogArticle,id=article_id)
pub = article.publish
return render(request,'blog/content.html',{'article':article,"publish":pub})