#25569: Add a friendly error report when using select_related() on a reverse
relation
-------------------------------------+-------------------------------------
     Reporter:  Shai Berger          |                    Owner:  Vincent
                                     |  Perez
         Type:  New feature          |                   Status:  assigned
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

 The patch turned out a lot more complicated than I thought it would be,
 and I'm not sure if it's worth it. In the original report, Shai said the
 error message refers to fields as "non-existent" but as far as I see, the
 error message is something like:

  FieldError: Invalid field name(s) given in select_related: 'choice_set'.
 Choices are: (none)".

 Since the choices are there, I think it's already clear whether there's a
 typo or if the field isn't supported by `select_related()`. With the
 patch, the error turns into:

  FieldError: Invalid field name(s) given in select_related: 'choice_set'
 (reason: reverse relational field). Choices are: (none).

 We have similar error messages elsewhere and this might set a precedent
 for doing more work to "improve" them similarly. Other opinions welcome.

--
Ticket URL: <https://code.djangoproject.com/ticket/25569#comment:11>
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.8fb6fac7174f20a0026b87a5b4926e84%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to