I am doing like this:
def hydrate(self, bundle):
manipulate data here
Now, based on the data, I want to check whether its already available or not. And want to create object if it doesnt exist already. Simply saying, want to do get_or_create.
You have hardly any code so I don't know what your models etc are around it but I think what you're looking for is:
我认为你正在寻找super ,它允许你通过在type
上调用super
来覆盖,扩展或预先添加任何类的方法
You can do that by overriding the obj_create method and using get_or_create function:
def obj_create(self, bundle, request=None, **kwargs):
....
But that doesn't sound like a good idea. Create means create and return already existing data..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.