Source code for superdjango.db.default.managers

# Imports

from django.core.exceptions import ObjectDoesNotExist
from django.db import models

# Exports

__all__ = (
    "DefaultManager",
)


# Managers


[docs]class DefaultManager(models.Manager): """Supports the ``DefaultModel``. .. code-block:: py from superdjango.db.default.managers import DefaultManager from superdjango.db.default.models import DefaultModel class Currency(DefaultModel): code = models.CharField(max_length=4) name = models.CharField(max_length=64) default_currency = Currency.objects.default() """
[docs] def default(self): """Get the default record.""" try: return self.get_queryset().get(is_default=True) except ObjectDoesNotExist: return None