How to override and call super on response_change or response_add in django admin

I would like to override response_change

in ModelAdmin to update a field in the parent window. After doing the update, I would like to return control to the overridden one response_change

.

A simplified version of what I've tried:

class MyModelAdmin(admin.ModelAdmin):
    def response_change(self, request, obj):
        // perfom my actions
        super(MyModelAdmin, self).response_change(request, obj)

      

But I am getting AttributeError object - 'NoneType' has no attribute 'has_header'. Maybe I am not using super right ...?

+2


source to share


2 answers


You need to return the result of calling super ().



return super(MyModelAdmin, self).response_change(request, obj)

      

+11


source


Perhaps you could add a more detailed stack stack?



Where does the error occur? Are you creating an answer? Otherwise, it get_response

may implicitly return None

for this error.

0


source







All Articles