#13708: Improve ModelAdmin.save_model() [PATCH] ----------------------------------+----------------------------------------- Reporter: sebastian_noack | Owner: nobody Status: new | Milestone: Component: django.contrib.admin | Version: 1.2 Keywords: | Stage: Unreviewed Has_patch: 1 | ----------------------------------+----------------------------------------- The ModelAdmin class provides a save_model() method, which can be overriden easily to add some pre- or post-save hooks to the admin. This is a good think and essential for some custom admins. But this API seems to be incomplete.
[[BR]] 1. There is no delete_model() method. If you can change the behaviour of saving a model instance though the admin why not doing the same for deleting an instance? 2. You can do anything in overriden save_model() methods, even skipping the save operation. Ususually custom form validation, is the way to go, if you want prevent the user from saving the data under some circumstences. But there are use cases, where you need a pre-save hook, which is only called after the form was validated successful, just before the model instance is saved into the database. This hook might fail for some reasons, and you don't want to save the instance in this case. You can implement it this way already, but the code calling save_model() does not care whether the model instance was saved succesful or not, right now. So an admin.LogEntry and an auth.Message object, claiming that the object was added/changed succesdful is created, doesn't matter if it was saved or not. This can be handled by letting save_model() and delete_model() return a boolean indicating, whether the instance was really saved or deleted. -- Ticket URL: <http://code.djangoproject.com/ticket/13708> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.
