A non-standard, compressed unique value is not a UUID. Also, this forces database backends to store the value in a string datatype and doesn't allow taking advantage of uuid specific datatypes. E.g. Postgresql couldn't use its uuid datatype. Any data can be made safe for any specific usage, e.g. URLs, but there is no reason to enforce this requirement in all uses of the data because not everyone will expose a UUID in a URL.
-1 from me. Regards, Michael Manfre On Sat, Dec 6, 2014 at 11:31 AM, Radek Svarz <[email protected]> wrote: > Hi, I am glad to see the UUID field coming to 1.8 > > Bellow is how we do it now in 1.7. > > The advantages: > > - it only uses 21 chars (instead of 32) > > - chars are safe for URLs > > - uuid is created when default is called > > I advocate to have the short websafe representation. What do you think? > > code: > >> def safe_uuid(): >> return uuid.uuid4().bytes.encode('base64').rstrip('=\n').replace('/', >> '_') >> > > >> class UUIDField(CharField) : >> """ >> UUIDField stored in 21 Chars >> Example: uuid = UUIDField(primary_key=True, editable=False) >> """ >> description = "UUIDField stored in 21 Chars" >> def __init__(self, *args, **kwargs): >> kwargs['max_length'] = kwargs.get('max_length', 22 ) >> kwargs['default'] = safe_uuid >> CharField.__init__(self, *args, **kwargs) >> >> def deconstruct(self): >> name, path, args, kwargs = super(UUIDField, self).deconstruct() >> return name, path, args, kwargs > > > Radek > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/1c29dfae-6483-465c-939e-f4319120781f%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/1c29dfae-6483-465c-939e-f4319120781f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAGdCwBtMjX_OHTkExpd7a8o7VfnG7AvXoV64TOvhoHd2W0_AGA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
