用临时数据库启动django shell
发布时间:2020-05-24 11:06:47 所属栏目:MsSql 来源:互联网
导读:我想用一个临时数据库启动 django shell(就像做django测试时所做的那样) 有没有像这样的命令: python manage.py testshell 我可以创建一堆虚假模型而不污染我的数据库? 没关系,这 blog post解释了它 from django import test test.utils.setup_test_environ
|
我想用一个临时数据库启动 django shell(就像做django测试时所做的那样) 有没有像这样的命令: python manage.py testshell 我可以创建一堆虚假模型而不污染我的数据库? 解决方法没关系,这 blog post解释了它>>> from django import test >>> test.utils.setup_test_environment() # Setup the environment >>> from django.db import connection >>> db = connection.creation.create_test_db() # Create the test db (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
