使用 fixtures 启动 django liveserver
Start django liveserver with fixtures
有什么方法可以使用干净的数据库启动 django 开发实时服务器并加载我选择的测试装置吗?
是的,看看the documentation for the testserver
command:
django-admin testserver
Runs a Django development server (as in runserver) using data from the given fixture(s).
For example, this command:
django-admin testserver mydata.json
...would perform the following steps:
- Create a test database, as described in The test database.
- Populate the test database with fixture data from the given fixtures. (For more on fixtures, see the documentation for loaddata above.)
- Runs the Django development server (as in runserver), pointed at this newly created test database instead of your production database.
您可以使用以下命令将灯具加载到数据库中:
python manage.py loaddata data.json
有什么方法可以使用干净的数据库启动 django 开发实时服务器并加载我选择的测试装置吗?
是的,看看the documentation for the testserver
command:
django-admin testserver
Runs a Django development server (as in runserver) using data from the given fixture(s).
For example, this command:
django-admin testserver mydata.json
...would perform the following steps:
- Create a test database, as described in The test database.
- Populate the test database with fixture data from the given fixtures. (For more on fixtures, see the documentation for loaddata above.)
- Runs the Django development server (as in runserver), pointed at this newly created test database instead of your production database.
您可以使用以下命令将灯具加载到数据库中:
python manage.py loaddata data.json