haystack安装后导致Django版本强制升级为3.2引发的不兼容性问题
发布日期:2021-05-07 00:13:59 浏览次数:11 分类:技术文章

本文共 617 字,大约阅读时间需要 2 分钟。

1 背景

在pip install django-haystack时

在这里插入图片描述
Django原本是1.11.11, 安装这个包之后会自动升级为3.2版本, 它这个包需要的Django版本必须要高于2.2
在这里插入图片描述
报错信息是:

'Specifying a namespace in include() without providing an app_name ’

django.core.exceptions.ImproperlyConfigured: Specifying a namespace in
include() without providing an app_name is not supported. Set the
app_name attribute in the included module, or pass a 2-tuple
containing the list of patterns and app_name instead.

2 解决问题

不难分析, 这个应该是Django由1.X升级到3.X带来的新问题

Django3.X要改为下面这种写法
在这里插入图片描述
但现在又出了一堆警告, 大致意思就是现在需要自动创建主键应该要声明
于是我们来到配置文件(默认是settings.py), 在后面添加一句

DEFAULT_AUTO_FIELD = ‘django.db.models.AutoField’

在这里插入图片描述

现在就又可以正常使用啦~

上一篇:ASM mov指令与lea指令的区别
下一篇:美多商城项目楼层Logo图片不显示

发表评论

最新留言

表示我来过!
[***.240.166.169]2025年03月16日 04时08分33秒