One thing I like about Rails projects is that you can create test content and place them in seeds.rb
and seed them into the database by running rake db:seed
instead of having to feed them one by one directly.
我喜欢Rails项目的一点是,您可以创建测试内容并将其放入种子中。rb并通过运行rake db:seed将它们放入数据库中,而不是必须逐个地将它们输入。
Is there something similar for Python/Django?
Python/Django有类似的东西吗?
2 个解决方案
#1
1
It sounds like migrations or fixtures may be what you are looking for.
听起来迁移或设备可能是您要寻找的。
Migrations would be Python code that can add data or manipulate the database schema. Fixtures would be JSON formatted data that can be used as an initial data seed by using python manage.py loaddata $FIXTURE
.
迁移将是可以添加数据或操作数据库模式的Python代码。fixture是JSON格式的数据,可以使用python管理作为初始数据种子。py loaddata固定美元。
#2
0
I would also recommend looking at Factory Boy for test data creation. One could create records in series of loops to population any number of tables and build sensible relationships between records.
我还建议使用Factory Boy来创建测试数据。可以创建一系列循环中的记录来填充任意数量的表,并在记录之间建立合理的关系。
#1
1
It sounds like migrations or fixtures may be what you are looking for.
听起来迁移或设备可能是您要寻找的。
Migrations would be Python code that can add data or manipulate the database schema. Fixtures would be JSON formatted data that can be used as an initial data seed by using python manage.py loaddata $FIXTURE
.
迁移将是可以添加数据或操作数据库模式的Python代码。fixture是JSON格式的数据,可以使用python管理作为初始数据种子。py loaddata固定美元。
#2
0
I would also recommend looking at Factory Boy for test data creation. One could create records in series of loops to population any number of tables and build sensible relationships between records.
我还建议使用Factory Boy来创建测试数据。可以创建一系列循环中的记录来填充任意数量的表,并在记录之间建立合理的关系。