I'm not sure how this is more transparent. Don't you mean *less*
transparent for your user? Instead of a simple number (or more usable
user-defined slug), you're giving them a random string, which will be
almost impossible to remember and contains no discernibly useful
information. If you *really* need a "feature" like this, why not just
do something involving strftime as the slug:

def save(self):
    if not self.slug:
        import datetime
        self.slug = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
    super(Project, self).save()

And if you use usernames as part of your URL, you can maintain data
integrity by including this in class Meta:

unique_together = (('user', 'slug),)

Remember that "standard operating procedure" (what YouTube, the US
Gov, et al., are doing) isn't necessarily the same thing as "best
practice." Long random strings are simply unusable, at least in the
context you intend to use them.

(Sorry if I sound like a scold.)

On Mon, Mar 31, 2008 at 4: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 like www.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/
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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