#33441: model Field.__hash__ should be immutable
-------------------------------------+-------------------------------------
Reporter: Adam Johnson | Owner: Adam
| Johnson
Type: Bug | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
> But there are plenty of uses for fields in ORM expressions that *might*
lead one to create references to a field before/after they are assigned to
a model class.
Could you go into more detail about this statement? Fields meant to be
assigned/bound to a model class should all be set after the app setup
phase and no fields should be bound to a model class after this point so
I'm struggling to come up with the plenty of uses in ORM expressions you
are referring to. Just saying that providing concrete examples might help
your case here.
Ideally, we'd have a notion of `BoundField(model: Model, field: Field)` to
avoid having to differentiate between fields attached to models and ones
that aren't based of `.model` (that's what we do in django.forms for
example) but that's a large change for sure.
As for reverting the patch for the `__hash__` part I'm not against it,
from what I understand and what Adam pointed out it should not break
anything. If believe strongly that inherited fields should have they own
`__hash__` then maybe we could simplify this whole thing by having the
interitance logic ''bump'' `creation_counter` instead?
--
Ticket URL: <https://code.djangoproject.com/ticket/33441#comment:4>
Django <https://code.djangoproject.com/>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.35475c2dd4571ae544ac9fca355a8c2c%40djangoproject.com.