Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 7, 2011 11:18:42

r.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django admin - action on delete


What action is initialized when delete link is clicked?
I user save_model() to override default save action, but can't find action
to override delete procedures. I need it:/

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 7, 2011 13:53:16

Scott H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django admin - action on delete


On Jan 7, 5:18 am, robos85 <prog...@gmail.com> wrote:
> What action is initialized when delete link is clicked?
> I user save_model() to override default save action, but can't find action
> to override delete procedures. I need it:/

Every model has a delete() method. You should be able to override it.http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.delete--
Scott Heberthttp://slaptijack.com--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 7, 2011 15:14:44

Mark (.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django admin - action on delete


There is a warning in on overriding delete, maybe not a concern for
you but worth knowing about.:http://docs.djangoproject.com/en/dev/topics/db/models/Note that the delete() method for an object is not necessarily called
when deleting objects in bulk using a QuerySet. To ensure customized
delete logic gets executed, you can use pre_delete and/or post_delete
signals.

On Jan 7, 4:18 am, robos85 <prog...@gmail.com> wrote:
> What action is initialized when delete link is clicked?
> I user save_model() to override default save action, but can't find action
> to override delete procedures. I need it:/

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 7, 2011 15:22:16

g.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django admin - action on delete


I made what I wanted in
def log_deletion(self, request, object, object_repr):

It's not elegant, but in Django 1.3 there is a delete_model() function:)
But now I'm using 1.2.4 :)

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 Jan. 7, 2011 17:36:24

Subhranath C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django admin - action on delete


When deleting from the admin interface, the delete is actually on the entire
QuerySet rather than on the object level. So if you need to perform some
object level modification on the delete action of the admin interface, you
can remove the default 'delete_selected' action, and go a custom delete
action. Like:

class SomeModelAdmin(admin.ModelAdmin):
actions =
def custom_delete(self, request, queryset):
for object in queryset:
perform_some_action(object)
object.delete()
custom_delete.short_description = "Delete selected items"

def get_actions(self, request):
actions = super(SomeModelAdmin, self).get_actions(request)
del actions
return actions

Thanks,
Subhranath Chunder.

On Fri, Jan 7, 2011 at 8:52 PM, galago <prog...@gmail.com> wrote:

> I made what I wanted in
> def log_deletion(self, request, object, object_repr):
>
> It's not elegant, but in Django 1.3 there is a delete_model() function:)
> But now I'm using 1.2.4 :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 11th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support