为什么 Permission table 填充在测试数据库中,而其他的则没有(django python)?
Why is Permission table populated in test database, while others aren't (django python)?
在玩 django 测试时,我注意到测试数据库中的 Permission
table 不为空(例如,模型的 User
和 tables由我定义)-它拥有真实 table 的所有权限。
我的问题:
-
Permission
table 是唯一预填充的 table 吗? (我无法检查其他 tables,因为数据库在内存中)
- 预填充在哪里(我也找不到)?设置测试服后?或者就在执行每个测试方法之前?或者可能在每次请求时添加到查询集中?
权限是在您 运行 manage.py migrate
, there is a signal handler that listens to the post_migrate
发出信号并为每个新模型创建这些权限时创建的。
ContentType table 也将以类似的方式填充
当您 运行 测试时,您的测试数据库将应用您的迁移
在玩 django 测试时,我注意到测试数据库中的 Permission
table 不为空(例如,模型的 User
和 tables由我定义)-它拥有真实 table 的所有权限。
我的问题:
-
Permission
table 是唯一预填充的 table 吗? (我无法检查其他 tables,因为数据库在内存中) - 预填充在哪里(我也找不到)?设置测试服后?或者就在执行每个测试方法之前?或者可能在每次请求时添加到查询集中?
权限是在您 运行 manage.py migrate
, there is a signal handler that listens to the post_migrate
发出信号并为每个新模型创建这些权限时创建的。
ContentType table 也将以类似的方式填充
当您 运行 测试时,您的测试数据库将应用您的迁移