Chapter03
3.1.1
报错提示:
TemplateSyntaxError at /blog/
'blog_tags' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_static
admin_urls
cache
i18n
l10n
log
static
staticfiles
tz
解决方法:
TEMPLATES = [
{
# ...
'libraries': {
'blog_tags': 'blog.tempaltetags.blog_tags',
}
},
},
]
Chapter07
7.4.5
报错提示:运行 celery -A myshop flower
启动flower失败
解决方法:查看安装flower所依赖的tornado版本是否大于6,若是,降级到5.1.1
Chapter08
8.1.2
报错提示:payment/process.html
模版错误
解决方法:
<script src="https://js.braintreegateway.com/web/3.29.0/js/hostedfields.min.js"></script>
改为
<script src="https://js.braintreegateway.com/web/3.29.0/js/hosted-fields.min.js"></script>
8.4
报错提示:运行项目时报错,缺少cairo等依赖
解决方法:安装cairo
Chapter09
9.2
报错提示:执行django-admin makemessages --all
,报错提示Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed
,系统中已安装过gettext,执行brew link gettext --force
时报错Error: No such keg: /usr/local/Cellar--force
解决方法:重新安装gettext
Chapter10
10.5.2
报错提示:运行开发服务器,打开http://127.0.0.1:8000
,报错
TypeError at /course/mine/ 'AnonymousUser' object is not iterable
,错误代码定位到return qs.filter(owner=self.request.user)
解决方法:清空浏览器缓存,打开上述链接时,不是经过验证的用户,导致报错,
可以先打开127.0.0.1:8000/accounts/login
,选择一个账户登陆后,再打开上述链接。
10.5.3
报错提示:报错TemplateSyntaxError ... is not a registered tag lib
解决方法:在settings中加入以下设置
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'libraries':{
'courses': 'courses.templatetags.course',
}
},
},
]