python - Abstract inheritance from models in third party Django packages -
to abstract model inheritance in django, put
class meta: abstract = true
in parent model. mean impossible abstractly inherit model not have meta statement? specifically, not possible abstractly inherit model in existing model in third party package (unless change model)?
here example clarify asking. let's there django package called djangofoo i've installed in project's installed_apps. in djangofoo.models, let's have
from django.db import models class person(models.model): first_name = models.charfield(max_length=10) last_name = models.charfield(max_length=25)
i sub-class person in 1 own apps follows
from djangofoo.models import person class myperson(person): middle_initial = models.charfield(max_length=1)
however, concrete inheritance. possible abstract inheritance? here's fictitious example of kind of magic looking for:
from djangofoo.models import person abstractperson = abstractify(person) class myperson(abstractperson): middle_initial = models.charfield(max_length=1)
of course change person model definition in djangofoo.models add appropriate abstract = true statement, preferable not have obvious reasons.
Comments
Post a Comment