#30955: Document the different behavior of migration historical models while
they
have abstract base classes.
------------------------------------------------+------------------------
Reporter: fengsp | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+------------------------
In the documentation of
[https://docs.djangoproject.com/en/2.2/topics/migrations/#historical-
models migrations], we have:
In addition, the base classes of the model are just stored as pointers,
so you must always keep base classes
around for as long as there is a migration that contains a reference to
them. On the plus side, methods and
managers from these base classes inherit normally, so if you absolutely
need access to these you can opt to move
them into a superclass.
However, this is not the case for abstract base classes, for example:
{{{
#!python
class ModelMixin(object):
def method_in_mixin(self):
pass
class BaseModel(ModelMixin, models.Model):
class Meta:
abstract = True
create_time = models.DateTimeField(db_column='create_time',
auto_now_add=True)
def method_in_abstract(self):
pass
}}}
In historical models, we can access {{{method_in_mixin}}}, but we can not
access {{{method_in_abstract}}}.
I have a look at the source code and find out that abstract base classes
won't appear in the bases of the
historical model.
If this is the desired behavior, I'd like it to be documented:
In addition, the base classes (excluding abstract base classes) of the
model are just stored as pointers, so
you must always keep base classes...
If this is the right solution, I'd love to open a pull request to fix the
docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/30955>
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/049.dcc838182d2462b8cd5f86b2e3b28297%40djangoproject.com.