#11108 closed (fixed)
add a ModelAdmin.delete_model method, similar to ModelAdmin.save_model (+patch)
Reported by: | thomas | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | sprintnov13 | |
Cc: | jay.wineinger@…, Florian Apolloner | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When we delete an object, it could be usefull to have the "request" attribute. For example to know "how is doing this delete", as shown as the exemple with save_model (http://docs.djangoproject.com/en/1.0/ref/contrib/admin/#modeladmin-methods).
My very little patch creates a ModelAdmin.delete_model(self, request, obj) method, one can override in admin.py.
I use it in a custom log system, where I log all details of all modifications of a object, with the "modifier" who make the modification (request.user). I can log creations and modifications with save_model, now I can log delete() too.
Thanks.
Attachments (4)
Change History (19)
by , 15 years ago
Attachment: | contrib-admin-options-py.diff added |
---|
comment:1 by , 15 years ago
Version: | 1.0 → SVN |
---|
follow-up: 4 comment:2 by , 15 years ago
Cc: | added |
---|---|
Needs documentation: | set |
Needs tests: | set |
Patch needs improvement: | set |
from the trac-view of the patch above
1022 self.delete_model(request, obj) 1017 1023 1018 1024 self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') %...
Slight bug -- if you don't actually delete the object, the message will still show. Similar bug with the delete log message?
comment:3 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 15 years ago
Cc: | added |
---|
Replying to shadfc:
Slight bug -- if you don't actually delete the object, the message will still show. Similar bug with the delete log message?
not really imo, delete_model is expected to delete the object, so I guess this will fall under documentation (remember you confirmed that you really want to delete it already…)
by , 15 years ago
Attachment: | delete_model@11970.diff added |
---|
comment:5 by , 15 years ago
Needs documentation: | unset |
---|---|
Patch needs improvement: | unset |
My testsuite is currently failing, but I guess that cause my settings.py isn't configured for multidb tests
by , 14 years ago
Attachment: | delete_model@14387.diff added |
---|
comment:7 by , 14 years ago
milestone: | → 1.3 |
---|
Updated the patch to apply cleanly on current trunk, do we really need tests here? the delete functionality should already be covered by the view tests?
comment:8 by , 14 years ago
Keywords: | sprintnov13 added |
---|
by , 14 years ago
Attachment: | delete_model.diff added |
---|
comment:10 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:11 by , 14 years ago
This should also include this change in actions.py:
47c47 < modeladmin.delete_model(request,obj) --- > queryset.delete()
To have the same result using delete_selected from actions.
comment:12 by , 14 years ago
Divad, you might want to open a new ticket if you'd like to make more changes. This ticket is closed, so your idea is likely to be forgotten if it stays here.
comment:13 by , 14 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Thanks julien, I will reopen.
comment:14 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
You should open a new ticket, not reopen old ones…
patch to add ModelAdmin.delete_model() in contrib.admin.options.py