#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 Vincent Perez):

 A simpler alternative could be to simply adjust the error message if there
 is at least one reverse relation amongst the incorrect fields. In that
 case, the error message would be:

 >FieldError: Invalid field name(s) given in select_related: 'choice_set'.
 Choices are: (none)". Reverse relational fields are not allowed in
 select_related.

 This way, the patch will indeed be much simpler .

 But the message won't be more friendly for generic relation and generic
 FK, which are also forbidden. Is it a big deal? If the answer to this last
 question is yes, I could adjust the previous logic and simply do: if there
 is at least one reverse relation, generic FK or generic relation amongst
 the incorrect fields, then I display the message:

 >FieldError: Invalid field name(s) given in select_related: 'choice_set'.
 Choices are: (none)". Reverse relational fields, Generic relations and
 generic foreign keys are not allowed in select_related.

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

Reply via email to