Hi,

On 16/02/12 10:53, SomeoneToIgnore wrote:
Hello. I'm using Django 1.3.1.

I've got some strange behaviour while deleting an object in admin
panel.

Here's the code from models.py:

class Poll(models.Model):
     question = models.CharField(max_length=200)
     pub_date = models.DateTimeField('date published')

     def was_published_today(self):
         return self.pub_date.date() == datetime.date.today()
     was_published_today.short_description = 'Published today?'

     def __unicode__(self):
             return self.question

     def delete(self, using=None):
         print "Deleted"
         super(Poll, self).delete(using)

It is just the code from django tutorial with delete() method
overriden.

There was an issue:
https://code.djangoproject.com/ticket/11022

If I open the object's properties page and delete an object using
Delete button on that page everything works fine and message displays
in the console.

But if I check the object's checkoxes (insted of opening their
property list pages), select "Delete selected polls" action and press
the Go button, the Delete multiple objects page opens.
Then I press "Yes, I'm sure button" and objects are successfully
deleted.

But their delete() method are not triggered so i don't get the message
"Deleted" in the console.
It does not matter if I choose one or multiply objects - the message
still does not appear in the console.

Should I consider this behaviour as a bug or I am doing something
wrong?


The delete select action uses the queryset's delete method [1], which means the model's delete method is not called.

It's not a bug, the behaviour is documented on the admin actions page. [2]

Cheers,
Alasdair

[1]: https://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects [2]: https://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#admin-actions

--
Alasdair Nicol
Developer, MEMSET

mail: alasd...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, Guildford, 
Surrey, GU2 7YD, UK.

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

Reply via email to