Opened 5 years ago
Last modified 5 years ago
#31843 closed Bug
django.db.models.query.Row is not pickleable. — at Version 1
| 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 (last modified by )
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.
Change History (1)
comment:1 by , 5 years ago
| Description: | modified (diff) |
|---|---|
| Summary: | PicklingError: Can't pickle <class 'django.db.models.query.Row'>: attribute lookup Row on django.db.models.query failed → django.db.models.query.Row is not pickleable. |
| Triage Stage: | Unreviewed → Accepted |
Note:
See TracTickets
for help on using tickets.