Opened 2 years ago
Closed 2 years ago
#33823 closed Cleanup/optimization (fixed)
inspectdb should generate related_name on same relation links.
Reported by: | whysage | Owned by: | whysage |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi!
After models generation with inspectdb command we have issue with relations to same enities
module.Model.field1: (fields.E304) Reverse accessor for 'module.Model.field1' clashes with reverse accessor for 'module.Model.field2'.
HINT: Add or change a related_name argument to the definition for 'module.Model.field1' or 'module.Model.field2'.
*
Maybe we can autogenerate
related_name='attribute_name'
to all fields in model if related Model was used for this table
Change History (10)
comment:3 by , 2 years ago
Has patch: | set |
---|
follow-up: 5 comment:4 by , 2 years ago
Needs tests: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Summary: | Inspectdb add related_name on same relation link → inspectdb should generate related_name on same relation links. |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
Version: | 4.0 → dev |
Sounds reasonable. Tests are required.
follow-up: 6 comment:5 by , 2 years ago
Replying to Mariusz Felisiak:
Sounds reasonable. Tests are required.
Hi Mariusz Felisiak!
Thank you for reply.
Now I should add some unit tests?
comment:7 by , 2 years ago
comment:8 by , 2 years ago
Replying to Mariusz Felisiak:
Now I should add some unit tests?
Yes, please.
Test added:
https://github.com/django/django/pull/15819/commits/085896099ba04e86ed8cd54779e1daf5079dacd5
comment:9 by , 2 years ago
Needs tests: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
FIrst solution variant was - https://github.com/django/django/pull/15816
But now I see it is not correct.
I'l be back with new pull request