For anyone listening in...
the ticket http://code.djangoproject.com/ticket/2705 might also be
worth looking at

On Sep 6, 11:39 am, kmpm <pe...@birchroad.net> wrote:
> > UUIDs are your best bet. Even if you generated 100 billion UUIDs a
> > second for the next 100 years, the chance of one collision would only
> > be 50% [1].
>
> > class ProducedEntity(models.Model):
> >     ....
> >     uuid = models.CharField(max_length=36, unique=True)
>
> > def _hook_add_uuid(instance, sender, **kwargs):
> >     import uuid
> >     if not hasattr(instance, 'uuid') or not instance.uuid:
> >         instance.uuid = str(uuid.uuid4())
>
> > from django.db.models.signals import pre_save
> > pre_save.connect(_hook_add_uuid, sender=ProducedEntity)
>
> > UUIDs can be stored more efficiently than that, its just a big 128 bit
> > number, so can be stored as 2 long integers. See your DB manual for
> > more info.
>
> > Cheers
>
> > Tom
>
> > [1]http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUI...
>
> First of all to everyone, thanks for all good suggestions so far.
>
> Regarding UUIDs, one of the business requirements (which I don't
> control) is that the identifier that is to be used on barcodes and
> what not is to be in the format "YYMMDDXXXX" where XXXX is the number
> we are talking about. So UUID would be great and unique, as well would
> the automatic pk/id from the model itself as that is unique enough.
> But I need a rolling number per day and nothing else.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to