Sometimes, there is a particular feature that we want to be able to add to several different models. Repeating the same code in different files is bad programming practice, so it would be nice to be able to implement it once and be able to reuse it many times.
Abstract models allow us to just create a generic model that implements some feature that can then be inherited by regular models in order to make that feature available in them.
As an example, we will implement a simple
Archive feature. It adds the
active field to the model (if it doesn't exist already) and makes available an archive method to toggle the
active flag. This works because
active is a magic field; if present in a model by default, ...