在Django shell启动时自动导入模型 [英] Automatically import models on Django shell launch
本文介绍了在Django shell启动时自动导入模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
。有没有办法在我启动shell时自动运行这个命令?解决方案安装django-extensions,其中一个命令它的功能(shell_plus)为您的模型提供了上下文。
https://github.com/django-extensions/django-extensions
所以,而不是 ./ manage.py shell
,你可以使用 ./管理.py shell_plus
,以便导入所有内容。
I'm tired of typing from account_import.models import ImportFile
every time I open my Django shell. Is there a way to automatically run this command whenever I fire up my shell?
解决方案 install django-extensions, one of the commands it features (shell_plus) is providing the context for your models.
https://github.com/django-extensions/django-extensions
So, instead of ./manage.py shell
you can use ./manage.py shell_plus
so that everything is imported.
这篇关于在Django shell启动时自动导入模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文