Changes between Initial Version and Version 1 of Ticket #33682, comment 3
- Timestamp:
- May 6, 2022, 11:12:50 AM (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #33682, comment 3
initial v1 7 7 If 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. 8 8 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.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** perhaps even explicit inclusion of such a (non) field would cause the problem. 10 10 11 11 I 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.