【发布时间】:2018-05-10 00:24:25
【问题描述】:
在下面这段代码中,代码self._for_write是什么意思?
def create(self, **kwargs):
"""
Create a new object with the given kwargs, saving it to the database
and returning the created object.
"""
obj = self.model(**kwargs)
self._for_write = True
obj.save(force_insert=True, using=self.db)
return obj
【问题讨论】:
-
它正在使用 QuerySet 类的未记录属性。见this question。