I found an example here, which works really well:
http://www.ibm.com/developerworks/blogs/page/johnston?entry=cool_django

However, I've also seen on several forums and groups that having UUID
as primary key is not good at all for performance, especially when
executing inner joints and so on.
So I finally decided to keep the incremental integer as ID, and use
the UUIDField as a slug, which defaults with a random uuid string, and
which the user is free to modify to a more friendly slug such as
"myproject", given it has not already been taken by someone else.

What do you think is best practice? Also, how do you explain that
youtube, for example, only uses a dozen characters (and not 36 like a
UUID) to identify videos?

Cheers!


On Mar 31, 9:12 pm, Julien <[EMAIL PROTECTED]> wrote:
> I agree slugs are a lot nicer. In fact, I already have implemented
> those, so you can choose to refer to your project by a slug, given
> that slug hasn't already been taken by someonelse, in which case you
> need to choose another one.
>
> But by default projects don't have slugs, just an ID. I'll give a goo
> at UUID, but at first sight it looks like it manipulates huge strings
> (e.g. "550e8400-e29b-41d4-a716-446655440000"). A dozen characters
> would be largely enough for me, but maybe there's a way to shrink that
> massive string. I'll look into it.
>
> Any idea welcome, thank you!
>
> On Mar 31, 8:50 pm, "Bram de Jong" <[EMAIL PROTECTED]> wrote:
>
> > why not use slugs then?
>
> >http://www.example.com/projects/username/my-cool-project/
>
> > sounds a lot nice than
>
> >http://www.example.com/projects/0sdf0s463sdg0/
>
> >  - bram
>
> > On Mon, Mar 31, 2008 at 11:21 AM, Julien <[EMAIL PROTECTED]> wrote:
>
> > >  One reason is because I believe string allows to store bigger amounts
> > >  of data, since IDs wouldn't be counted in base 10. E.g. YouTube videos
> > >  which are identified by random generated strings.
> > >  Another reason is because I want to keep things a bit more transparent
> > >  to the users. Instead of having a url likewww.example.com/projects/3/,
> > >  I'd have something like  www.example.com/projects/iuyf876ertg/
> > >  I don't really want the user to know that his project is number 3...
>
> > >  On Mar 31, 8:11 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> > >  > On 31-Mar-08, at 2:30 PM, Julien wrote:
>
> > >  > > I just thought I'd try to make it clearer what I'm after. Instead of
> > >  > > having numbers as ID for my objects, I'd like to have random strings
> > >  > > (e.g. "sadfwetbtyvt32452" or "fd70982876adhfd"...). Those strings 
> > > have
> > >  > > to be unique across the table.
> > >  > > Is that easily achievable? Am I on the right track with the code
> > >  > > above?
>
> > >  > why? what do you hope to achieve by doing this?
>
> > >  > --
>
> > >  > regards
> > >  > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
>
> > --http://freesound.iua.upf.eduhttp://www.smartelectronix.comhttp://www....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to