jazzband / jazzband/django-model-utils
bulk deletion of subclass objects not working
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 374
- PR merge metrics
- No merged PRs in 30d
Description
If I create a series of models roughly like this:
```
class A(PolymorphicModel):
some fields ...
class B(A):
# no extra fields... just new methods
class C(A):
# no extra fields... just new methods
....
```
then create some objects:
```
B().save()
C().save()
```
and then try and delete them:
```
A.objects.all().delete()
```
then I get an error something like "'C' object has no attribute 'b_ptr'"
Whereas if I delete them individually:
```
[i.delete() for i in A.objects.all()]
>[None, None]
```
then all is fine. I'm not sure if this is a bug or a feature, but it's frustrating because I'm going to have to override the admin to make deletion of inline objects work (I'm using B and C only to override methods on A, no additional fields are stored).
Contributor guide
Research direction
Start by reproducing the failure with the A, B, and C model examples and the A.objects.all().delete() call described in the issue. Inspect Django model-utils' polymorphic bulk-deletion path; done means deleting the subclass instances through A.objects.all().delete() succeeds without the b_ptr error, while individual deletion continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100