python - Examine current messages in Django admin.py -
using django 1.5, python 2.7
is there way can examine messages have been added message object in admin.py
file? in admin model, overwriting save_model
function, , stop "model changed" message if doesn't meet criteria.
from django.contrib import admin, messages class exampleadmin(admin.modeladmin): list_display = ('whatever', 'etc') def save_model(self, request, obj, form, change): obj.save() # want @ messages right here
use get_messages
.
example:
from django.contrib import admin, messages class exampleadmin(admin.modeladmin): list_display = ('whatever', 'etc') def save_model(self, request, obj, form, change): obj.save() storage = messages.get_messages(request) message in storage: # examine message here. pass
Comments
Post a Comment