Make GenericForeignKey a subclass of Field
When introduced in bca5327b21eb2e3ee18292cbe532d6d0071201d8, GenericForeignKey was created as its own class. Since then, it has grown to resemble a field, particularly in fb48eb05816b1ac87d58696cdfe48be18c901f16.
GenericForeignKey *not* being a Field
leads to several issues:
- It is added as a “field” and returned by
Model._meta.get_fields()
, a type confusion reflected in django-stubs.
- It duplicates code, such as
_check_field_name()
.
- It misses methods like
__repr__()
.
I think we should make it a subclass of Field
.
(GenericRelation
has always been a subclass of Field
.)
Change History
(10)
Description: |
modified (diff)
|
Description: |
modified (diff)
|
Summary: |
Make GenericForeignKey subclass Field → Make GenericForeignKey a subclass of Field
|
Triage Stage: |
Unreviewed → Accepted
|
Owner: |
changed from nobody to Dylan Patrick Go
|
Owner: |
Dylan Patrick Go removed
|
Status: |
assigned → new
|
Owner: |
set to Adam Johnson
|
Status: |
new → assigned
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
I'm eager to see what the test suite says but it seems like a worth cleanup!