导入django中的所有模块

发布于 2024-09-14 04:54:09 字数 146 浏览 3 评论 0原文

在django中有没有办法导入所有模块

   ex: from project.models import *
   ex: from project1.models import *

这可以用一条语句来完成吗

In django is there way to import all modules

   ex: from project.models import *
   ex: from project1.models import *

Can this be done with one statement

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

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

发布评论

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

评论(1

冷夜 2024-09-21 04:54:09

如果您只想在 shell 中测试内容时执行此操作,请查看 django-extensions 项目。

这是一个非常简洁的扩展,当您从命令行执行 ./manage.py shell_plus 时,它会启动一个 shell 并自动加载项目中的所有模型。

If you just want to do this when testing things in the shell, look into the shell_plus command provided by the django-extensions project.

This is a really neat extension, which starts a shell and automatically loads all the models in your project when you do ./manage.py shell_plus from the command line.

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