#27365: Fields suddenly not found.
-------------------------------------+-------------------------------------
     Reporter:  Brandon              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.9
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  FieldDoesNotExist    |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Brandon):

 * status:  closed => new
 * resolution:  needsinfo =>


Comment:

 After stepping completely through the call stack down from
 {{{MySubclassOfaModelSubclass.objects.filter(id=1234)}}} we arrive at
 {{{get_related_field}}} in reverse_related.py Line# 237

 The call in this function that fails is {{{field =
 self.model._meta.get_field(self.field_name)}}}
 It fails because {{{self.field_name}}} has somehow been set to
 {{{self.name}}}.

 I cannot directly reproduce the error on demand. But setting
 {{{self.field_name = self.name}}} from a breakpoint at Line# 237
 reproduces *exactly* the stack trace I am (and have been) receiving on
 multiple independent production instances running first under
 Apache+mod_wsgi then nginx+uWSGI since moving from 1.7 to 1.9 months ago.

 I replicated the production stack trace via pudb checking every function
 scoped local variable along the way against a production stack trace that
 logged those variables on a failure. I checked them down from
 {{{.filter}}} to {{{.get_related_field}}}; all populated variables are
 identical down the complete call stack. The only way to reproduce that
 complete call stack and exact exception is to set {{{self.field_name =
 self.name}}} where {{{self}}} is a {{{OneToOneRel}}} representing
 {{{MySubclassOfaModelSubclass}}} - note that it actually shows up from
 repr as {{{<OneToOneRel: myapp.mysubclassofamodelsubclass>}}}

 I apologize for continually reopening this ticket. If there is another (or
 better) avenue to continue delivering detail around this issue, I'm
 certainly open to it. This has been a major thorn in my side. I'll provide
 any and all information necessary to get to the bottom of this very subtle
 and difficult issue. I'll be happy to work-up and submit a patch once the
 root cause is located.

 Thanks,
 --Brandon

 P.S. Please note that it is not just
 {{{MySubclassOfaModelSubclass.objects.filter(id=1234)}}} that fails. Any
 forward FK relation can fail (so
 {{{MySubclassOfaModelSubclass.objects.filter(foo_id=55)}}}) - and fails in
 exactly the same way. The MySubclassOfaModelSubclass class has many
 forward FKs in it. It doesn't seem to matter which FK field is accessed,
 the stack trace is always the same.

--
Ticket URL: <https://code.djangoproject.com/ticket/27365#comment:10>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/088.1a78b010a823d2cc8b7a83299e364b14%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to