WIP make content models swappable, closes #1160 #1935
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(It's marked as WIP because one test fails, but it fails on the vanilla 4.3.1 too, and we can
always discuss the coding style and naming. Github is warning about a merge conflict only because I don't have a proper 4.3.1 branc to base upon.)
Any of the following models can now be swapped by your own version:
So you can keep the same features and API but add fields, methods, inherit from
other classes (geo models for geo fields, third-party models...), etc.
without having to resort to model inheritance.
Just make sure you inherit from each respective abstract base class.
Contrary to my first submission, I kept the BaseXXX classes for a
smoother transition path.
I didn't change imports or references in the admin modules, I followed
UserAdmin conventions here. You'll have to explicitly register, e.g. PageAdmin
to your swapped Page model.
No docs update yet, let's first agree on code and naming conventions, what will
become the public API for users. This includes whether we provide
default values in the template project settings or in the code.
I also guess this deprecates the field injection feature, before removing it in
a future major version.
Now I wonder if I went too far. Initially I just wanted to swap the BlogPost model to inherit from GeoModel too, but this became useless with Django 2.0 (when Mezzanine will be compatible), and getting rid of the table inheritance of RichTextPage and Link may require a long deprecation path.
Besides that, it must be 100% compatible, no test changes apart from imports.