def get_active_entry(user, select_for_update=False):
    entries = apps.get_model('entries', 'Entry').no_join
    if select_for_update:
        entries = entries.select_for_update()
    entries = entries.filter(user=user, end_time__isnull=True)

    if not entries.exists():
        return None
    if entries.count() > 1:
        raise ActiveEntryError('Only one active entry is allowed.')
    return entries[0]
Returns the user's currently-active entry, or None.
dataset/ETHPy150Open caktus/django-timepiece/timepiece/utils/__init__.py/get_active_entry