<-- In admin.py I have a function it showing my custom message but also showing default success message how to stop default success message ??-->
from django.contrib import messages, admin
def save_model(self, request, obj, form, change):
self.message_user(request, "The message", level=messages.SUCCESS)
答案 0 :(得分:0)
尝试像这样在ModelAdmin中覆盖response_add方法
class YourModelAdmin(admin.ModelAdmin)
.......
def response_add(self, request, obj, post_url_continue=None):
msg = "Your message"
self.message_user(request, msg, level=messages.SUCCESS)
return self.response_post_save_add(request, obj)