Creating a model mixin to handle creation and modification dates
It is a common behavior to have timestamps in your models for the creation and modification of your model instances. In this recipe, we will see how to create a simple model mixin that saves the creation and modification dates and times for your model. Using such a mixin will ensure that all the models use the same field names for the timestamps and have the same behavior.
If you haven't done this yet, create the
utils package to save your mixins. Then, create the
models.py file in the
How to do it…
models.py file of your
utils package and insert the following content there:
# utils/models.py # -*- coding: UTF-8 -*- from __future__ import unicode_literals ...