Changes between Initial Version and Version 1 of Ticket #30976
- Timestamp:
- Nov 10, 2019, 2:30:45 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #30976
- Property Summary ManyToManyField does not create JOIN when target object contains a ForeignKey with the same name as the default reverse_query_name → ManyToManyField does not create JOIN when target object contains a ForeignKey with the same name as the default related_query_name
-
Ticket #30976 – Description
initial v1 71 71 This happens because the field accessor creates this implicit filter from the target model: `UserGroup.objects.filter(entity__entity_id=2)`. It assumes the default reverse name, which happens to conflict with the `entity` field on the target model. 72 72 73 A workaround is to simply supply the `re verse_query_name` argument on the `ManyToManyField` with something other than `"entity"`. However, it took me quite a while to figure out what was happening here.73 A workaround is to simply supply the `related_query_name` argument on the `ManyToManyField` with something other than `"entity"`. However, it took me quite a while to figure out what was happening here. 74 74 75 Django already warns about conflicting reverse names. It seems that there should also be a warning for this case.75 Django already warns about conflicting reverse relation names. It seems that there should also be a warning for this case.