Django Book 翻译
菜单>:
TOC
返回
原文:
The most difficult part of our Django use has been the relationship of memory objects to database objects, in a few ways. First, Djangos ORM does not ensure that two references to the same database record are the same Python object, so you can get into situations where two parts of the code are both trying to modify the same record, and one of the copies is stale. Second, the Django development model encourages you to base your data objects on database objects. Weve found over time more and more uses for data objects that are not tied to the database, and weve had to migrate away from assuming that data is stored in the database.
翻译:
内存对象和数据库对象之间的关系是, in a few ways,Django 的使用中最难的部分。第一,Django的ORM并不能保证,对同一个数据库记录的两此引用是来自同一个Python对象,所以你可能会遇到这种情况:代码中的两个部分要修改同一数据库记录,而其中一个的数据是旧的。第二,Django 开发模型鼓励你在数据库对象的基础上建立你的数据对象。我们会发现更频繁的超时,更多地使用那些没有对应到数据库的数据对象,我们只好不再假定数据是保存在数据库里的。
备注:
译者: