Opened 4 years ago
Last modified 4 years ago
#31843 closed Bug
PicklingError: Can't pickle <class 'django.db.models.query.Row'>: attribute lookup Row on django.db.models.query failed — at Initial Version
Reported by: | Vitaliy Yelnik | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.1 |
Severity: | Normal | Keywords: | pickle namedtuple values_list |
Cc: | Sergey Fedoseev | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The new named parameter of QuerySet.values_list() was released In Django 2.0 (#15648).
But resulted namedtuple-s can't be pickled:
class ModelA(models.Model): value = models.CharField(max_length=12)
In [12]: row = ModelA.objects.values_list('id', 'value', named=True).first() In [14]: type(row) Out[14]: django.db.models.query.Row In [16]: pickle.dumps(row) PicklingError: Can't pickle <class 'django.db.models.query.Row'>: attribute lookup Row on django.db.models.query failed
In particular, as a result, such requests do not work with cacheops package.
Note:
See TracTickets
for help on using tickets.