可以在保存后获取save_model函数中的对象。例如:
def save_model(self, request, obj, form, change):
o = super(CampaignAdmin, self).save_model(request, obj, form, change)
# do something with "o"
答案 0 :(得分:2)
save_model
所做的就是致电obj.save()
。因此你可以这样做:
def save_model(self, request, obj, form, change):
obj.save()
# Do something with obj
如果您愿意,也可以致电super()
,然后再使用obj
。
def save_model(self, request, obj, form, change):
# this returns None so don’t assign it to anything
super(CampaignAdmin, self).save_model(request, obj, form, change)
# Do something with obj