#35772: Document models.Field.contribute_to_class
-------------------------------------+-------------------------------------
Reporter: Clifford Gama | Owner: Clifford
Type: | Gama
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: contribute_to_class | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):
* cc: James Bennett (added)
* resolution: => wontfix
* status: assigned => closed
Comment:
Hello Clifford, thank you for taking the time to create this ticket.
It took me a while to gather information to have an opinion on your
proposal. Initially it seemed like a good idea and I couldn't find
duplicated ticket reports. Then, I searched some more and found a decent
list of resources describing/talking about `contribute_to_class` (in
chronological order, and there are more):
*
[
https://code.djangoproject.com/wiki/DevModelCreation#InstallingTheAttributes
Django's Wiki 2006]
* [
https://lazypython.blogspot.com/2008/11/django-models-digging-little-
deeper.html Alex Gaynor's post 2008]
* [
https://www.b-list.org/weblog/2019/mar/04/class/ James Bennet's post
2019]
* [
https://jacobian.org/til/django-model-fields-with-attributes/ Jacob
KM's TIL 2023]
The above certainly provides great and detailed documentation about
`contribute_to_class`, and I was thinking we could borrow from those to
add to the official docs, but then I read James' post where they say:
> And now it is time for the second warning in this post:
`contribute_to_class()` is an undocumented, private, internal API. Django
does not provide backwards-compatibility guarantees for it, and if you
make use of it you accept the risk that it might change or break at any
time.
Given that, I don't think we should accept this ticket without a previous
agreement with the community. Therefore, I'll close this ticket
accordingly, and the recommended path forward would be to first propose
and discuss the idea with the community and gain consensus (perhaps
tagging James may be a good idea). To do that, please consider starting a
new conversation on the [
https://forum.djangoproject.com/c/internals/5
Django Forum], where you'll reach a broader audience and receive
additional feedback.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35772#comment:1>