Changes between Initial Version and Version 1 of Ticket #33682, comment 3


Ignore:
Timestamp:
May 6, 2022, 11:12:50 AM (2 years ago)
Author:
Robert Leach

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #33682, comment 3

    initial v1  
    77If I'd better understood the *why* in that doc, I might have coded the right solution to the gotcha and not overlooked the other cases.
    88
    9 My updated understanding is that it seems that the reason *a* related model field is necessary is because the related model "field" in the model definition that links to the related model isn't a "field".  It's a reference that gets turned into a field that by default uses the `meta.ordering`.  (I didn't even notice that the distinct clause had `compound_id` and the order by clause had `name` in that position.)  So I'm guessing that *any*(?) related model field in front of a (non-field) related model reference (whether it's at the beginning of the distinct list or "just before" the non-field related model reference) would solve the issue?  Or will *any* explicit inclusion of a non-field related model reference cause the problem?  **Or** perhaps even explicit inclusion of such a (non) field would cause the problem.
     9My updated understanding is that it seems that the reason *a* related model field is necessary is because the related model "field" in the model definition that links to the related model isn't a "field".  It's a reference that gets turned into a field that by default uses the `meta.ordering`.  (I didn't even notice that the distinct clause had `compound_id` and the order by clause had `name` in that position.)  So I'm guessing that *any*(?) related model field in front of a (non-field) related model reference (whether it's at the beginning of the distinct list or "just before" the non-field related model reference) would solve the issue?  **Or** perhaps even explicit inclusion of such a (non) field would cause the problem.
    1010
    1111I think these are areas in which the doc could be improved just a bit more.  Understanding the /why/ **better**, I think, could be helpful to avoid these pitfals, and also help to understand an otherwise cryptic error message.
Back to Top