Opened 6 years ago
Closed 6 years ago
#31310 closed Cleanup/optimization (fixed)
Wrong hint about recursive relationship.
| Reported by: | Matheus Cunha Motta | Owned by: | Matheus Cunha Motta |
|---|---|---|---|
| Component: | Database layer (models, ORM) | 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: | yes | UI/UX: | no |
Description (last modified by )
When there's more than 2 ForeignKeys in an intermediary model of a m2m field and no through_fields have been set, Django will show an error with the following hint:
hint=( 'If you want to create a recursive relationship, ' 'use ForeignKey("%s", symmetrical=False, through="%s").'
But 'symmetrical' and 'through' are m2m keyword arguments, not ForeignKey.
This was probably a small mistake where the developer thought ManyToManyField but typed ForeignKey instead. And the symmetrical=False is an outdated requirement to recursive relationships with intermediary model to self, not required since 3.0. I'll provide a PR with a proposed correction shortly after.
Edit: fixed description.
Change History (7)
comment:2 by , 6 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 6 years ago
| Has patch: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:4 by , 6 years ago
| Needs tests: | set |
|---|---|
| Owner: | changed from to |
| Status: | new → assigned |
| Summary: | Wrong hint about recursive relationship → Wrong hint about recursive relationship. |
| Version: | 3.0 → master |
comment:5 by , 6 years ago
| Needs tests: | unset |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Here's a PR: https://github.com/django/django/pull/12497