Abstract model managers should return subclass instances
|Reported by:||jdunck||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.2|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Suppose a base:
class Document(Model): title = CharField() class Meta: abstract = True class Presentation(Document): num_kitten_pictures = IntegerField() class Spreadsheet(Document): num_pie_charts = IntegerField()
It would be useful if Documents.objects.filter(title='x') returned instances of both Presentation and Spreadsheet whose title was 'x'.
I'd expect support only for base-class fields. This should be safe, since inheritance should follow an is-a relationship.
Change History (9)
comment:4 Changed 4 years ago by jacob
- Triage Stage changed from Unreviewed to Design decision needed