#33273: queryset.update SQL does not receive fields from base model of
inheriting
model.
-----------------------------------------+------------------------
Reporter: James Miller | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
In an admin function, I receive a queryset with the class that was
registered with the admin decorator, @admin.register(ForumComment), where
the queryset is populated with ForumComments selected to approve, where
they have been reported for moderation.
In my approve_comment function, I use queryset.update(moderation=None).
The ForumComment model extends from a Comment model in another app. When
the code 'queryset.update(moderation=None) runs I get the following error:
```
*** django.db.utils.OperationalError: (1054, "Unknown column
'django_posts_and_comments_comment.date_created' in 'order clause'"
```
It seems that the queryset.update method is unable to scope the model
'ForumComment' to correctly include the methods/properties of the
superclass 'Comment'.
I have just returned to the code base after a while away, and I think that
it worked, and the error is new. I have solved the error by iterating
over the records of the queryset and saving each one individually using
update_fields for efficiency, but the queryset.update should work.
I have asked this question at the forum where I have included code etc.
https://forum.djangoproject.com/t/unknown-field-in-order-clause-when-
using-model-inheritance/10444/2
In sum, should it not be the case that queryset.update is capable of
generating SQL that will correctly include the fields of a superclass
model?
--
Ticket URL: <https://code.djangoproject.com/ticket/33273>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/059.182910411df9c07fdbaae5b5c20df292%40djangoproject.com.