#25361: Unpickling of QuerySet fails in presence of abstract intermediate model
-------------------------------------+-------------------------------------
     Reporter:  Torsten Bronger      |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Samuel Spencer):

 I just got bit by this and I can't say I've come across the best solution,
 but I was able to resolve it with this code in
 {{{/django/db/models/fields/__init__.py}}}:

 {{{
 --- __init__.py 2016-09-22 06:07:36.167725186 +0000
 +++ __init__.py.old     2016-09-22 06:08:19.175742789 +0000
 @@ -66,11 +66,6 @@
      return apps.get_model(app_label,
 model_name)._meta.get_field(field_name)


 -def _load_field_for_abstract(app_label, model_name, field_name):
 -    from django.utils.module_loading import import_string
 -    return import_string('%s.models.%s'%(app_label,
 model_name))._meta.get_field(field_name)
 -
 -
  # A guide to Field parameters:
  #
  #   * name:      The name of the field specified in the model.
 @@ -508,11 +503,7 @@
              # Deferred model will not be found from the app registry.
 This
              # could be fixed by reconstructing the deferred model on
 unpickle.
              raise RuntimeError("Fields of deferred models can't be
 reduced")
 -        if self.model._meta.abstract:
 -            func = _load_field_for_abstract
 -        else:
 -            func = _load_field
 -        return func, (self.model._meta.app_label,
 self.model._meta.object_name,
 +        return _load_field, (self.model._meta.app_label,
 self.model._meta.object_name,
                               self.name)

      def get_pk_value_on_save(self, instance):
 }}}

 {{{__init__.py.old}}} is the original from Django 1.8.14. I'm not sure
 where to begin with submitting and testing this, but I'd like to help if
 someone could give me some pointers.

--
Ticket URL: <https://code.djangoproject.com/ticket/25361#comment:2>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.ff1778b4dec0e897327e798f4d3ec25e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to