Changes between Initial Version and Version 1 of Ticket #30976


Ignore:
Timestamp:
Nov 10, 2019, 2:30:45 PM (5 years ago)
Author:
Ben Davis
Comment:

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_nameManyToManyField 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  
    7171This 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.
    7272
    73 A workaround is to simply supply the `reverse_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.
     73A 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.
    7474
    75 Django already warns about conflicting reverse names. It seems that there should also be a warning for this case.
     75Django already warns about conflicting reverse relation names. It seems that there should also be a warning for this case.
Back to Top