Skip to content

Latest commit

 

History

History
88 lines (54 loc) · 3.99 KB

models.rst

File metadata and controls

88 lines (54 loc) · 3.99 KB

Model Mixins and Base Classes

.. module:: django_goodies.models

CommonInfoMixin

CommonInfoMixin is a model mixin class that provides:

.. automethod:: save
.. automethod:: owned_by
.. seealso::

    :class:`~django_goodies.models.managers.CommonInfoManager`
        The custom Manager exposed by the ``objects`` attribute.

    :class:`~django_goodies.models.managers.CommonInfoQuerySet`
        The custom QuerySet exposed by ``CommonInfoManager``.

    :class:`~django_goodies.forms.CommonInfoForm`
        A ``ModelForm`` subclass to act as a base for ``CommonInfoMixin`` model forms.


ArchivableMixin

ArchivableMixin is a model mixin class that provides:

.. automethod:: archive
.. automethod:: unarchive
.. seealso::

    :class:`~django_goodies.models.managers.ArchivableManager`
        The custom Manager exposed by the ``objects``, ``live`` and ``archived`` attributes.

    :class:`~django_goodies.models.managers.ArchivableQuerySet`
        The custom QuerySet exposed by ``ArchivableManager``.


VersioningMixin

VersioningMixin is a model mixin class that provides:

.. automethod:: save

.. exception:: VersioningMixin.AmbiguousVersionError

    A subclass of :exc:`~django_goodies.exceptions.ModelAmbiguousVersionError` specific to the :class:`VersioningMixin` class. Raised when attempting to access the ``version`` field after it has been atomically incremented.
.. seealso::

    :class:`~django_goodies.models.managers.VersioningManager`
        The custom Manager exposed by the ``objects`` attribute.

    :class:`~django_goodies.models.managers.VersioningQuerySet`
        The custom QuerySet exposed by ``VersioningManager``.


StaticAbstract

StaticAbstract is a combination of :class:`CommonInfoMixin`, :class:`ArchivableMixin` and :class:`VersioningMixin`. It is designed as an abstract base class for models, rather than a mixin itself. It includes all the fields, as well as custom objects, live and archived managers, and provides access to all the functionality offered by each of the mixins.