Opened 5 years ago
Closed 5 years ago
#31258 closed Bug (worksforme)
Django admin deletes only one instance from many
Reported by: | Pavel-Y | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 2.2 |
Severity: | Normal | Keywords: | admin |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This is my first bug report here, hope I don't mess things too much.
I have this model. I have plenty of instances with the same name, same start_date and is_deleted=true. Also one instance with same name, same start_date but is_deleted=false.
When I go to admin page, mark _all_ those where is_deleted==true and delete them, I am asked if I am sure I want to delete. I answer Yes and I am returned to the previous page, to the list of instances. However only one of those instances is deleted.
I think it's a bug. I think all marked instances should be deleted.
Django 2.2.10, python 3.6.4
class Festival(models.Model): name = models.CharField(max_length=100) start_date = models.DateField(null=True) is_deleted = models.BooleanField(default=False) def __str__(self): return self.name def __lt__(self, rhs): if self.start_date is None: return False if rhs.start_date is None: return True return (self.start_date < rhs.start_date or self.start_date == rhs.start_date and self.name < rhs.name) def __eq__(self, rhs): return (self.start_date == rhs.start_date and self.name == rhs.name and self.is_deleted == rhs.is_deleted) def __hash__(self): return hash((self.name, self.start_date, self.is_deleted))
Hi Pavel.
Can you put together a minimal project demonstrating this issue please?
When I test as best I can from the description on a project it's all working as expected, so maybe there's more info needed to reproduce?
I'll close as "worksforme" for now, but if you can provide a test project, please do re-open.
Thanks.