#23624: Regression in ManyToManyField with through, runtime-generated models
-------------------------------------+-------------------------------------
Reporter: ludoo | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by bmispelon):
I've bisected the error to this commit:
9f13c3328199d2fa70235cdc63bb06b1efc5b117
Note that using Python3, you get a slightly more useful error message:
{{{
Traceback (most recent call last):
File "./django/db/models/fields/related.py", line 876, in get_queryset
return
self.instance._prefetched_objects_cache[self.prefetch_cache_name]
AttributeError: 'A' object has no attribute '_prefetched_objects_cache'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "t.py", line 20, in <module>
a.b_s.all() # works in 1.6, raises FieldError in 1.7
File "./django/db/models/manager.py", line 191, in all
return self.get_queryset()
File "./django/db/models/fields/related.py", line 882, in get_queryset
return qs._next_is_sticky().filter(**self.core_filters)
File "./django/db/models/query.py", line 691, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "./django/db/models/query.py", line 709, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "./django/db/models/sql/query.py", line 1287, in add_q
clause, require_inner = self._add_q(where_part, self.used_aliases)
File "./django/db/models/sql/query.py", line 1314, in _add_q
current_negated=current_negated, connector=connector)
File "./django/db/models/sql/query.py", line 1138, in build_filter
lookups, parts, reffed_aggregate = self.solve_lookup_type(arg)
File "./django/db/models/sql/query.py", line 1076, in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted,
self.get_meta())
File "./django/db/models/sql/query.py", line 1383, in names_to_path
self.raise_field_error(opts, name)
File "./django/db/models/sql/query.py", line 1389, in raise_field_error
"Choices are: %s" % (name, ", ".join(available)))
django.core.exceptions.FieldError: Cannot resolve keyword 'a' into field.
Choices are: a_s, id, name
}}}
(another interesting thing is that while bisecting, I encountered a
different error and even a RecursionError).
Still not sure if this is a bug in Django or if your use-case is just not
supported. It certainly looks weird.
--
Ticket URL: <https://code.djangoproject.com/ticket/23624#comment:5>
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/063.f52aeea71eab19de2dd32e92a06f183e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.