Changes between Version 3 and Version 5 of Ticket #35976
- Timestamp:
- Dec 7, 2024, 4:27:34 AM (8 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #35976
- Property Summary Persist original Meta class on Options instances → Document Options.original_attrs
-
Ticket #35976 – Description
v3 v5 1 When a `model.Model` class is created [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/base.py#L112 the metaclass `pop`s off] any `Meta` attribue defined on the model [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/base.py#L122 before calling] `super.__new__()`. We do [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/base.py#L145 pass it as an argument] to the `Options` class, and [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/options.py#L136 it's stored] on the `Options` instance, however [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/options.py#L232 this is then deleted] whilst the `Options.contribute_to_class` class is called. The attributes from the meta value are stored on a `original_attrs` attribute however. It might be a good idea to document th is!!1 When a `model.Model` class is created [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/base.py#L112 the metaclass `pop`s off] any `Meta` attribue defined on the model [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/base.py#L122 before calling] `super.__new__()`. We do [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/base.py#L145 pass it as an argument] to the `Options` class, and [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/options.py#L136 it's stored] on the `Options` instance, however [https://github.com/django/django/blob/ded485464214a3f69b64402b7d82221279f80008/django/db/models/options.py#L232 this is then deleted] whilst the `Options.contribute_to_class` class is called. The attributes from the meta value are stored on a `original_attrs` attribute however. It might be a good idea to document that this attribute exists. 2 2 3 3 === Motivation for the documentation ===