django:模块' django_mysql.models'没有属性' jsonfield;?

发布于 2025-02-11 01:26:12 字数 466 浏览 2 评论 0 原文

我正在运行Django 4.0。我有一个模型,上面宣告了这样的字段:

industries = models.JSONField()

在Makemigration上,Django抛出了错误:

模块'django_mysql.models'没有属性'jsonfield'

至少有3个以前的帖子。他们建议使用我正在做的Django的 models.jsonfield()

我正在使用:

  • DJANGO 4.0
  • PYTHON 3.9.13
  • DJANGO-MYSQL 4.7.0

为什么我会收到此错误消息?

更新

可能以某种方式相关:从2019年起,错误就会在旧的迁移文件中丢弃。

I'm running Django 4.0. I've got a models with fields declared like this:

industries = models.JSONField()

On MakeMigration, Django is throwing the error:

module 'django_mysql.models' has no attribute 'JSONField'

There are at least 3 previous SO posts on this. They advise using Django's models.JSONField(), which I am doing.

I'm using:

  • Django 4.0
  • Python 3.9.13
  • django-mysql 4.7.0

Why am I getting this error message?

Update

Possibly relevant somehow: the error is being thrown in an old migration file from 2019.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

握住你手 2025-02-18 01:26:12

感谢Willem van Onsem的答案。他指出,我仍然必须引用 django_mysql.models.jsonfield 以某种方式。果然,我有这样做的旧迁移文件。 (and 关于如何解决这个问题。)

@willem,如果您想以答案的形式发表评论,我将标记为接受的答案。

Thanks to Willem Van Onsem for the answer. He pointed out that I must still be referencing django_mysql.models.JSONField somehow. Sure enough, I had old migration files that were doing that. (And here's the SO thread about how to fix that.)

@Willem, if you'd like to post your comment in the form of an answer here, I will mark it as the accepted answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文