#22778: Specify default value for a Model's RelatedFields related_name. -------------------------------------+------------------------------------- Reporter: renaud.parent@… | Owner: anonymous Type: New feature | Status: assigned Component: Database layer | Version: master (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: | Needs documentation: 0 Has patch: 1 | Patch needs improvement: 1 Needs tests: 1 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+------------------------------------- Changes (by jorgecarleitao):
* cc: jorgecarleitao@… (added) * needs_tests: 0 => 1 Comment: Hi RenaudParent, thanks for the patch. I've reviewed your PR and made minor comments on the PR in github. It seems promising. As far as I can tell, the PR still requires: 1. The patch doesn't addressed Meta subclassing yet: i.e. what happens when the Model is subclassed? At the moment it seems the `default_related_name` is inherited, which can cause a clash; see [1]. 2. tests: it passes all tests means it is compatible with current Django functionality, which is great; however, we must ensure it is also compatible with what we want to achieve with it, namely, that if we add a `default_related_name` to `Meta`, the relations without `related_name` get the default one, while others don't. We may also want to test subclassing. 3. documentation: besides being in the API for Meta, it would be nice to document it in other places, specially in `docs/db/models`, section "Be careful with `related_name`". (after 1.-3.) 4. There should be an item in `docs/releases/1.X.rst` (X=8?) describing this new functionality. 5. If core devs agree, refactor tests where this new functionality can be useful. For example, the model `Book` in `tests/costum_managers/models.py` seems a good candidate. [1] https://docs.djangoproject.com/en/dev/topics/db/models/#be-careful- with-related-name -- Ticket URL: <https://code.djangoproject.com/ticket/22778#comment:8> 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 post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/081.6cb0234ca8d35cc4ed1d4dadf259f9bb%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.