我希望能够通过python控制台操纵Django应用程序的模型。我可以使用PyCharm做到这一点,但是在这种情况下我无法使用PyCharm。我尝试了这个:
[root@myhost scripts]# source /apps/capman/env/bin/activate
(env) [root@myhost scripts]# python
Python 2.7.14 (default, Jan 9 2018, 20:51:20)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> from vc.models import *
但是我得到了错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named vc.models
我究竟做错了什么?
您可能需要先启动Shell
python manage.py shell
然后运行
from vc.models import *
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句