#17917: Pickling queryset with annotations on related fields with callable
defaults
fails
---------------------------------+-----------------------------------------
Reporter: jensadne@… | Owner: nobody
Type: Bug | Status: new
Component: ORM aggregation | Version: SVN
Severity: Normal | Keywords: queryset,pickle,aggregation
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Given the following models:
{{{
#!python
class Person(models.Model):
name = models.CharField(max_length=32)
class LogEntry(models.Model):
person = models.ForeignKey(Person, related_name='log_entries')
created = models.DateTimeField(default=datetime.now)
}}}
the following function fails with
{{{
#!python
"TypeError: expected string or Unicode object, NoneType found":
}}}
{{{
#!python
def pickle_persons_with_latest_logentry_time():
qs =
Person.objects.all().annotate(latest_logentry_time=Max('log_entries__created'))
pickled = cPickle.dumps(qs)
}}}
Changing to using the pickle module instead of cPickle changes the
exception to:
{{{
#!python
PicklingError: Can't pickle <built-in method now of type object at
0x7f3e064bb020>: it's not found as __main__.now
}}}
so this looks related to #13328
Tested with Django 1.3.1 on python 2.4.3 (Centos 5), Django 1.3.1 on
python 2.7 (Fedora 14), and latest Django-SVN with python 2.7, and got the
same result on all of them.
--
Ticket URL: <https://code.djangoproject.com/ticket/17917>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.