inspectdb to quote ForeignKey class names to avoid need to reorder classes/solve circular dependencies
The inspectdb management command supplies either "self" or the unquoted name of foreign key's class as the first argument to the ForeignKey constructor. This requires that classes be defined prior to their first use. If the class name were supplied as a quoted string the ordering of classes isn't required. That would also solve the case where circular dependencies keep classes from being defined in an appropriate order.
I've attached the trivial changes as a diff from trunk 15194.
Component: |
Uncategorized → ORM aggregation
|
Owner: |
nobody removed
|
Triage Stage: |
Unreviewed → Design decision needed
|
Component: |
ORM aggregation → django-admin.py inspectdb
|
Owner: |
set to nobody
|
Component: |
django-admin.py inspectdb → Core (Management commands)
|
Severity: |
→ Normal
|
Type: |
→ Bug
|
Easy pickings: |
unset
|
UI/UX: |
unset
|
Keywords: |
inspectdb added
|
Triage Stage: |
Design decision needed → Accepted
|
Has patch: |
set
|
Needs tests: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
If I remember correctly, specifying the FK destination model name inside quotes doesn't work well when the model is already known, so a wholesale solution like this (always using quoting) can result in faulty introspected models.py's.