#27365: Fields suddenly not found.
-------------------------------------+-------------------------------------
Reporter: Brandon | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: FieldDoesNotExist | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Brandon):
I don't understand what you mean by "defining Django models and not
importing them in an application's models module or package".
Every model that is being used is beneath a package that is listed in
{{{INSTALLED_APPS}}}.
Let me describe the process.
Given this structure:
{{{
class Case(models.Model):
...lots of fields...
class SubclassCase(Case):
...lots more fields...
}}}
1. A user accesses a generic page that retrieves and renders the state of
a {{{Case}}} instance.
2. The user then, if they so choose, accesses a subclass specific page
that uses the {{{id}}} of the {{{Case}}} instance to retrieve the subclass
instance via a {{{SubclassCase.objects.get(id=case.id)}}}. The class
{{{SubclassCase}}} was imported via a {{{__import__}}} just moments before
the {{.get}} is done.
3. The subclass instance is then used to render a subclass specific page
that includes both {{{Case}}} and {{{SubclassCase}}} parameters.
This is one of 3 different but similar situations where I have seen this
bug expressed. Each situation centers around following an FK backwards via
on a subclass instance using {{{SubclassCase.objects.get(id=case.id)}}} or
{{{SubclassCase.objects.filter(id=case.id)}}}, where {{{id}}} is an
{{{AutoField}}}. As was noted in the original issue and in my post to the
forums (https://groups.google.com/d/msg/django-
users/S4AnygYSJqU/JttIqqTLAQAJ) once you reach {{{_filter_or_exclude}}}
the exception is *always* the same and the manner of the error is always
the same (i.e. The {{{field}}} variable seems to be populated by
{{{self}}} in {{{get_related_field}}} at line 244). The difference between
the 3 situations is, 2 of the 3 situations do *not* do the
{{{__import__}}}, only 1 of the 3 situations do the dynamic import.
--
Ticket URL: <https://code.djangoproject.com/ticket/27365#comment:4>
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.41481beb58248a8edac70c777a66d6e2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.