Re: [Django] #35224: Make GenericForeignKey subclass Field

2024-02-16 Thread Django
#35224: Make GenericForeignKey subclass Field
-+-
 Reporter:  Adam Johnson |Owner:  nobody
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:   |  Version:  dev
  contrib.contenttypes   |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by Adam Johnson:

Old description:

> 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` is confusing. It is added as a
> “field” and returned by `Model._meta.get_fields()`, a type confusion
> [https://github.com/typeddjango/django-
> stubs/blob/5a8e7b3855ea6f7be2b2ab928d02eff9a748d917/django-
> stubs/db/models/options.pyi#L122-L124 reflected in django-stubs]. It also
> duplicates code from `Field`.
>
> I think we should make it a subclass of `Field`.

New description:

 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:
 1. It is added as a “field” and returned by `Model._meta.get_fields()`, a
 type confusion [https://github.com/typeddjango/django-
 stubs/blob/5a8e7b3855ea6f7be2b2ab928d02eff9a748d917/django-
 stubs/db/models/options.pyi#L122-L124 reflected in django-stubs].
 2. It duplicates code, such as `_check_field_name()`.
 3. It misses methods like `__repr__()`.

 I think we should make it a subclass of `Field`.

--
-- 
Ticket URL: 
Django 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018db40c3013-86318be7-04d5-403c-ab91-90fd357bb181-00%40eu-central-1.amazonses.com.


[Django] #35224: Make GenericForeignKey subclass Field

2024-02-16 Thread Django
#35224: Make GenericForeignKey subclass Field
+--
   Reporter:  Adam Johnson  |  Owner:  nobody
   Type:  Cleanup/optimization  | Status:  assigned
  Component:  contrib.contenttypes  |Version:  dev
   Severity:  Normal|   Keywords:
   Triage Stage:  Unreviewed|  Has patch:  0
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  0
  UI/UX:  0 |
+--
 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` is confusing. It is added as a
 “field” and returned by `Model._meta.get_fields()`, a type confusion
 [https://github.com/typeddjango/django-
 stubs/blob/5a8e7b3855ea6f7be2b2ab928d02eff9a748d917/django-
 stubs/db/models/options.pyi#L122-L124 reflected in django-stubs]. It also
 duplicates code from `Field`.

 I think we should make it a subclass of `Field`.
-- 
Ticket URL: 
Django 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018db406f701-aaff97a4-ec5f-4af3-99c6-decc6d18c7b9-00%40eu-central-1.amazonses.com.