#30894: Reverse OneToOneField relation: `prefetch_related` uses `related_name` while `select_related` uses `related_query_name` -------------------------------------+------------------------------------- Reporter: Adam Sołtysik | Owner: nobody Type: | Status: closed Cleanup/optimization | Component: Documentation | Version: 2.2 Severity: Normal | Resolution: wontfix Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Carlton Gibson):
* status: new => closed * resolution: => wontfix * component: Database layer (models, ORM) => Documentation * type: Bug => Cleanup/optimization Comment: OK, yes. Your models work the same. It's the presence of the `related_query_name` which causes the failure. Remove it and it works, because (as per the docs) `related_query_name` defaults to `related_name` if that's set. At best this is a documentation cleanup/optimization **but** setting `related_query_name` explicitly is an much more specialised use case than setting `related_name`. I think the `related_query_name` docs are clear enough that setting it overrides the name of the reverse filter, and that a ''clarification'' in the `select_related()` docs would only muddy the water for the majority of users. (One should under the consequences before setting `related_query_name`.) -- Ticket URL: <https://code.djangoproject.com/ticket/30894#comment:2> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.2cc7fdc34d237770fd176c3b111ea60a%40djangoproject.com.