首先 如果版本和老师的一模一样的 ,就没事。我的是1.8.11 ,方法是修改setting.py
注意里面所有template 单词里面是否有s ,
TEMPLATES = [
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
。。。。。
'django.template.context_processors.debug',
'django.template.context_processors.request',
注意里面所有template 单词里面是否有s ,
TEMPLATES = [
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
。。。。。
'django.template.context_processors.debug',
'django.template.context_processors.request',
2018-02-26
对于提交文章后返回首页,老师用的不是一个好方法,参考Django官方文档,应该使用重定向返回首页
from django.http import HttpResponseRedirect
from django.urls import reverse
return HttpResponseRedirect(reverse('index'))
from django.http import HttpResponseRedirect
from django.urls import reverse
return HttpResponseRedirect(reverse('index'))
2018-02-26
对于python2.7没有pytz时区模块 需要命令行自行pip pytz模块 django才能安装成功
2018-02-10
python 3.6+django 2.0以上版本的同学注意一下
一共需要三处改动
<a href="{% url 'blog:article_page' article.id %}">{{ article.title }}</a>
path('blog/', include(('blog.urls', 'blog'), namespace=None))
app_name='blog'
一共需要三处改动
<a href="{% url 'blog:article_page' article.id %}">{{ article.title }}</a>
path('blog/', include(('blog.urls', 'blog'), namespace=None))
app_name='blog'
2018-02-07