# Imports
from django.db.models import Manager
# Exports
__all__ = (
"OwnedByManager",
)
# Managers
[docs]class OwnedByManager(Manager):
"""Manage records that are "owned" by a user.
.. code-block:: python
class Task(OwnedByModel):
objects = OwnedByManager()
my_tasks = Task.objects.owned_by(user)
"""
[docs] def owned_by(self, user):
"""Get records owned by the given users.
:param user: The user that owns the records.
:type user: AUTH_USER_MODEL
"""
return self.get_queryset().filter(owned_by=user)