PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` from typing import Any from typing import Dict from typing import Tuple from django.db import models from django.utils.translation import gettext_lazy as _ from . import ShortUUID class ShortUUIDField(models.CharField): description = _("A short UUID field.") def __init__(self, *args: Any, **kwargs: Any) -> None: self.length: int = kwargs.pop("length", 22) # type: ignore self.prefix: str = kwargs.pop("prefix", "") # type: ignore if "max_length" not in kwargs: # If `max_length` was not specified, set it here. kwargs["max_length"] = self.length + len(self.prefix) # type: ignore self.alphabet: str = kwargs.pop("alphabet", None) # type: ignore kwargs["default"] = self._generate_uuid # type: ignore super().__init__(*args, **kwargs) def _generate_uuid(self) -> str: """Generate a short random string.""" return self.prefix + ShortUUID(alphabet=self.alphabet).random( length=self.length ) def deconstruct(self) -> Tuple[str, str, Tuple, Dict[str, Any]]: name, path, args, kwargs = super().deconstruct() kwargs["alphabet"] = self.alphabet kwargs["length"] = self.length kwargs["prefix"] = self.prefix kwargs.pop("default", None) return name, path, args, kwargs