A pattern for Django model fields with sub-attributes (eg `obj.field.html`): https://jacobian.org/til/django-model-fields-with-attributes/
@jacob Good post. Do you think we should add a discussion like that to the docs?
It reminded me of Marc Tamlyn's at @djangoconeurope 2017...
@jacob I used this today. I'd done it ages ago reverse engineering ImageField. But so much faster with your example.
@carlton @djangoconeurope perhaps… But one thing I noticed writing it is that I don’t think contribute_to_class is documented anywhere! That for sure we should fix.
@jacob @carlton @djangoconeurope We have an accepted ticket to use __set_name__ instead in some cases
https://code.djangoproject.com/ticket/27880
@jacob @carlton @djangoconeurope I'm glad that contribute_to_class is documented here https://github.com/django/django/blob/38e391e95fe5258bc6d2467332dc9cd44ce6ba52/docs/ref/models/instances.txt#L937-L942 since I depend on it often as well!
It's a bit surprising. The method has been around since the merge of the magic removal branch after all.