在 django 中重命名应用程序

发布于 2025-01-06 11:44:06 字数 385 浏览 3 评论 0原文

我有一个应用程序,比如说电影,有一些模型和最初的向南迁移。现在我想将其名称更改为资源。因此,我创建了空的南数据迁移,并将所有表名称更改为相关,然后重命名应用程序文件夹、settings.py 中的应用程序名称和所有导入。看起来是正确的。但是当我运行迁移时,我收到:

django.core.exceptions.ImproperlyConfigured: App with label movies could not be found

但南标记迁移已完成。我应该改变什么来纠正它?

编辑:

我还应该重命名初始迁移中所有出现的“电影”吗?

编辑2: 当我尝试迁移干净的表时也会出现此问题。然后南尝试为应用程序电影创建表,它已经重命名为资源。

I had app lets say movies, with some models and initial south migration. Now I want to change its name to resource. So I created empty south data migration and changed all table names to relevant and then renamed app folder, app name in settings.py and all imports. It looks correct. But when I run migration I receive:

django.core.exceptions.ImproperlyConfigured: App with label movies could not be found

But south mark migration as completed. What should I change to correct it?

EDIT:

Should I also rename all occurences of 'movies' in initial migration?

EDIT2:
The problem also occurs when I try to migrate over clear tables. Then south try to create tables for app movies and it is already renamed to resource.

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

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

发布评论

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

评论(1

请爱~陌生人 2025-01-13 11:44:06

我使用了一种 hacky 解决方案来解决这个问题。但我没有看到任何其他的。我更改了初始迁移,因此它创建资源表而不是电影表,并且在迁移中更改表名称,我将命令包装到

try..except

块中

I used a hacky solution to solve this one. But I don`t see any other one. I changed initial migration so it creates resource tables not movies ones, and in migration which changes tables names I wrapped commands into

try..except

block

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