[Django] #32509: Manytomany relations not loaded even it exists

12 views
Skip to first unread message

Django

unread,
Mar 5, 2021, 2:28:01 AM3/5/21
to django-...@googlegroups.com
#32509: Manytomany relations not loaded even it exists
-------------------------------------+-------------------------------------
Reporter: amatmv | Owner: nobody
Type: Bug | Status: new
Component: Core | Version: 2.1
(Management commands) | Keywords: manytomany,
Severity: Normal | database
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi,

we run a production ecommerce with an average of ~50k sessions per day. In
the last few weeks we're facing a constant error in production where many
queries are throwing the same error, but in different situations.
The error is: "Cannot resolve keyword <field> into field. Choices are:
..."

I acknowledge that this error is thrown whenever we're trying to join a
table through a field that doesn't exist in the model, but the thing is
that now we daily get thousands of this error in different situations,
apparently in random parts of the code.

I also know that there is the method `prefetch_related` that loads the M2M
relations, but are we supposed to -right now- do a deploy calling this
method in all the places that we get the same error?

Thank you!!

--
Ticket URL: <https://code.djangoproject.com/ticket/32509>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 5, 2021, 2:53:40 AM3/5/21
to django-...@googlegroups.com
#32509: Manytomany relations not loaded even it exists
-------------------------------------+-------------------------------------
Reporter: amatmv | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.1
(models, ORM) | Resolution:
Severity: Normal | worksforme
Keywords: manytomany, | Triage Stage:
database | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => worksforme
* component: Core (Management commands) => Database layer (models, ORM)


Comment:

> I also know that there is the method prefetch_related that loads the M2M
relations, but are we supposed to -right now- do a deploy calling this
method in all the places that we get the same error?

`prefetch_related` is not related with the fields available on models.

There is not enough details to reproduce the issue and prove it's an issue
in Django. Also, Django 2.1 is not supported anymore. Can you reproduce
this issue with Django 3.1+ and provide a small sample project?

--
Ticket URL: <https://code.djangoproject.com/ticket/32509#comment:1>

Django

unread,
Mar 5, 2021, 2:53:48 AM3/5/21
to django-...@googlegroups.com
#32509: Manytomany relations not loaded even it exists
-------------------------------------+-------------------------------------
Reporter: amatmv | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution: needsinfo

Keywords: manytomany, | Triage Stage:
database | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* resolution: worksforme => needsinfo


--
Ticket URL: <https://code.djangoproject.com/ticket/32509#comment:2>

Reply all
Reply to author
Forward
0 new messages