python3.7.4+django2.2.3
改動一處
path('blog/',include((blog.urls),'blog'),namespace='blog')
附錄:
<a href="{% url 'blog:article' article.id %}">{{article.title}}</a>
其中,
urls后面那個字符串'blog:article':
blog是你的根目錄urls.py文件的namespace的值,
article是你的應用程序目錄urls.py文件的name的值。
改動一處
path('blog/',include((blog.urls),'blog'),namespace='blog')
附錄:
<a href="{% url 'blog:article' article.id %}">{{article.title}}</a>
其中,
urls后面那個字符串'blog:article':
blog是你的根目錄urls.py文件的namespace的值,
article是你的應用程序目錄urls.py文件的name的值。
2019-07-28
def article_page(request,article_id):
article = models.Article.objects.get(pk=article_id)
#錯誤.前面加了blog/
#return render(request,'blog/article_page.html', {'article': article})
return render(request,'article_page.html',{'article':article})
article = models.Article.objects.get(pk=article_id)
#錯誤.前面加了blog/
#return render(request,'blog/article_page.html', {'article': article})
return render(request,'article_page.html',{'article':article})
2019-07-17