Opened 10 years ago
Closed 9 years ago
#24305 closed New feature (fixed)
Allow overriding abstract model fields
Reported by: | Marten Kenbeek | Owned by: | Aron Podrigal |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Marten Kenbeek, Aron Podrigal, ramezashraf@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Discussion on django-developers: https://groups.google.com/forum/#!topic/django-developers/6zUfnElOIks
I suggest we allow fields that are only defined on an abstract base class of a model, to be overridden by models directly inheriting the abstract class. As fields on an abstract class are python-only, and don't live in the database yet, they can easily be switched for another field. If you use abstract models from sources outside your control, or if you reuse an abstract model multiple times, this allows for some flexibility without the need to copy the complete abstract class.
Change History (18)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 10 years ago
Has patch: | set |
---|
PR: https://github.com/django/django/pull/4184
Feedback welcome, especially on the documentation.
comment:4 by , 9 years ago
Patch needs improvement: | set |
---|
Chatted with Loic briefly and he indicated he didn't think the locking approach is an appropriate implementation. The approach also needs to integrate with the upcoming work on virtual fields, so it may take some time to sort that out.
comment:5 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 9 years ago
Patch needs improvement: | unset |
---|
There is a commit here with an alternate approach: https://github.com/knbk/django/commit/7ac5b58587ea2a153766d1601965734731609cdf (having difficulty finding what branch it's part of so I could create a pull request).
comment:9 by , 9 years ago
Patch needs improvement: | unset |
---|
comment:10 by , 9 years ago
Cc: | added |
---|
comment:11 by , 9 years ago
Patch needs improvement: | set |
---|
The patch is missing some tests cases as noted in Loic's review.
comment:12 by , 9 years ago
Patch needs improvement: | unset |
---|
comment:13 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:14 by , 9 years ago
Cc: | added |
---|---|
Triage Stage: | Ready for checkin → Accepted |
I believe that the correct ticket flow is a person other then who supplied the patch can mark Ready For Checkin.
Kindly review
https://docs.djangoproject.com/en/1.8/internals/contributing/new-contributors/#new-contributors-faq
and
https://docs.djangoproject.com/en/1.8/internals/contributing/triaging-tickets/
Thanks
comment:15 by , 9 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
I reviewed the patch and asked Aron to mark the patch as such after updating for my comments. :-)
comment:17 by , 9 years ago
Summary: | Allow to override abstract model fields → Allow overriding abstract model fields |
---|
WIP: https://github.com/knbk/django/tree/ticket_24305