Djaogn-2-by-Example_Errors_Correct

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',
                 }
        },
    },
]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值