#32170: Admin select_related is different to the model's select related
-------------------------------+--------------------------------------
     Reporter:  Michael        |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Uncategorized  |                  Version:  3.1
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
Description changed by Michael:

Old description:

> In a model one can do `.select_related('foo__bar')`.
>
> However in the admin view if one has `select_related = ('foo__bar', )`
> it raises the error `Non-relational field given in select_related: 'bar'.
> Choices are: ...`. One has to do `select_related = ('foo', )`. Hence  to
> select only certain fields, one has to override the `get_queryset`.
>
> Seems a bit inconsistent? I guess it goes hand in hand with not allowing
> foreign key fields in list display (#5863) etc.

New description:

 In a model one can do `.select_related('foo__bar')`.

 However in the admin view if one has `select_related = ('foo__bar', )`  it
 raises the error `Non-relational field given in select_related: 'bar'.
 Choices are: ...`. One has to do `list_select_related = ('foo', )`. Hence
 to select only certain fields, one has to override the `get_queryset`.

 Seems a bit inconsistent? I guess it goes hand in hand with not allowing
 foreign key fields in list display (#5863) etc.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32170#comment:1>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.b2df42a2c928119714d2080a220c1b62%40djangoproject.com.

Reply via email to