bulk deletion of subclass objects not working
See original GitHub issueIf 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).
Issue Analytics
- State:
- Created 12 years ago
- Comments:7
Top Results From Across the Web
AttributeError Exception raised when trying to bulk delete ...
I'm trying to bulk delete all of the comments on a dev instance of my Django website and Django is raising an AttributeException....
Read more >Chapter 7. Batch processing - Red Hat on GitHub
However, Hibernate provides methods for bulk SQL-style UPDATE and DELETE statement execution which are performed through JP-QL (Chapter 8, JP-QL: The Object ......
Read more >Common Hibernate Exceptions - Baeldung
Many conditions can cause exceptions to be thrown while using Hibernate. These can be mapping errors, infrastructure problems, SQL errors, ...
Read more >Models - Django documentation
Be careful not to choose field names that conflict with the models API like clean , save , or delete . Example: from...
Read more >Working with Objects - Doctrine
Removing entities · Just like persist , invoking remove on an entity does NOT cause an immediate SQL DELETE to be issued on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m not sure what code this applies to, since there is no
PolymorphicModelin django-model-utils and never has been.yeah sorry, could have added that. I am finding that it’s not just on a bulk delete. When I set
publishedtoFalseon a model instance and save it I get an error as per below:Model Definitions:
And the object manager as posted above: