def save(self):
とすると、create()とget_or_create()で以下のようなエラーを吐いた。
TypeError: save() got an unexpected keyword argument 'force_insert'
saveにforce_insert,force_updateを渡すようにしないといけないらしい。
正解はこう
def save(self, force_insert=False, force_update=False):
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges
create() and get_or_create() will never update existing objects ¶
In [8670] a change was made to both create() and get_or_create() that affects people in two ways:
Firstly, if you have a custom save() method on your model and it is going to be called using create() or get_or_create(), you should make sure you accept the force_insert parameter (best to accept force_update as well, just like django.db.models.base.Model.save()). You don't have to do anything with these parameters, just pass them through to the Model.save() method.
0 件のコメント:
コメントを投稿