backend/passfinder/utils/choices.py

10 lines
270 B
Python
Raw Normal View History

2023-05-18 20:25:22 +03:00
from collections.abc import Iterable
from django.db.models.enums import ChoicesMeta
2023-05-21 13:37:21 +03:00
def count_max_length(choices: any):
2023-05-18 20:25:22 +03:00
if isinstance(choices, ChoicesMeta):
return max([len(val) for val in choices.values])
return max([len(val) for val, _ in choices])