When overriding methods you should call super(), not the methods
directly on parent classes. super() will resolve the method order
correctly, and in this case it'll call delete_model() all the way back
in ModelAdmin, which is the base class of PageAdmin.
Here's an example on how to call super() on save_model()
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model
On 2017-10-19 1:29 PM, Rainell Dilou Gómez wrote:
Hello everyone
I tried to override "RichTextPageAdmin" to use the /save_model/ and
/delete_model/ methods when creates or deleted RichText type pages.
The code would be something like this
|
classRichTextPageAdmin(PageAdmin):
defdelete_model(self,request,obj):
# do something
returnPageAdmin.delete_model(self,request,obj)
defsave_model(self,request,obj,form,change):
# do something
returnPageAdmin.save_model(self,request,obj,form,change)
ifRichTextPageinadmin.site._registry:
admin.site.unregister(RichTextPage)
admin.site.register(RichTextPage,RichTextPageAdmin)
|
So, when I saw that the test worked only with the save_model method, I
noticed that the delete_model method does not exist in the PageAdmin
class.
So I'm wondering, how can I execute a code when a RichText type page
is deleted?
--
You received this message because you are subscribed to the Google
Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Mezzanine
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.