django - model.save() 在加载 Django fixtures 时没有被调用?

标签 django testing fixtures django-fixtures sanity-check

我正在覆盖我的 Django 模型 save() 方法,因此我可以对对象进行一些额外的健全性检查。 (save() 是执行此操作的正确位置吗?)

我的 fixtures/initial_fixtures.yaml 对象似乎没有调用它们的 save() 方法。我怎样才能健全地检查我的固定装置?

最佳答案

从 Django 1.5 开始,不调用 save():

When fixture files are processed, the data is saved to the database as is. Model defined save() methods are not called, and any pre_save or post_save signals will be called with raw=True since the instance only contains attributes that are local to the model.

https://docs.djangoproject.com/en/1.9/ref/django-admin/

关于django - model.save() 在加载 Django fixtures 时没有被调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7879948/

相关文章:

python - Django 中的应用名称与旧应用名称冲突

django - 操作系统错误 : [Errno 2] No such file or directory: '/tmp/MakeCalls/Static'

ruby - 如何调用参数传递的名称的方法?

ruby-on-rails-4 - Rails 4 fixtures 不生成 ID(Hartl 教程 9.6.2)

database - 回滚条令数据 :load when insert from fixtures fails

symfony1 - symfony Doctrine :build --all --and-load WITHOUT LOSING RECORDS IN DATABASE

django - Restangular 因 promise 和跨域请求而失败

javascript - 如何将 FilePond 指向 django 媒体文件

laravel - 发出 HTTP 请求并用数据填充它

testing - 关于编写场景(功能测试)的主要想法?