Hi James,

Thanks for your feedback. Actually I was thinking that this randomly
generated number with 15 digits will be used in urls, for example of pages
which don't have slugs etc. I saw similar urls in Facebook for pages who
don't have a username (Facebook calls it a username), Facebook generates a
slug which contains a 15-digits number. I found out that Facebook redirects
to this url when entering the url with only the number (for example
https://www.facebook.com/342076035998592/ - with or without the trailing
slash, even with several slashes). So the UUID will be too long for this,
unless I generate it with 15 digits (decimal). And how do I make it a
primary key of model User? Is there a way to change the primary keys of
Django models and how? I think we will use PostgreSQL anyway, thanks!

Uri.

*Uri Even-Chen*
[image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
<http://www.facebook.com/urievenchen>  <http://plus.google.com/+urievenchen>
  <http://www.linkedin.com/in/urievenchen>  <http://twitter.com/urievenchen>

On Thu, Feb 4, 2016 at 6:52 PM, James Schneider <jrschneide...@gmail.com>
wrote:

>
> >
> > So my question is, can I make this random ID the primary key of the User
> model? I don't want users to have 2 ids - one for Django and one of Speedy
> Net, it doesn't make sense. I want the id to be the same and unique. I also
> want to have an Id model to prevent a page and a user (for example) to have
> the same ID. And a Username model to prevent them from having the same
> username. Is it possible to do it with Django 1.9.2?
> >
>
> Rather than coming up with some arbitrary numbering scheme that will be
> difficult to manage, you should really just be using a UUID field, which
> provides the same benefits and can be used as the PK quite easily. Projects
> with large numbers of rows often go this route, since there is effectively
> an unlimited number of UUID's.
>
> https://docs.djangoproject.com/en/1.9/ref/models/fields/#uuidfield
>
> If you can, use Postgres as your backend DB, since it has native support
> for UUID's, other DB's will simply treat them as CharFields, which will
> still work but is slightly less efficient.
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciV-O_LLcZ86rpT3_VbHM8aLXDLjocVw92SHtUuCg43wAA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2Be%2BciV-O_LLcZ86rpT3_VbHM8aLXDLjocVw92SHtUuCg43wAA%40mail.gmail.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 users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMQ2MsE9%3DjUH%2BNNjzG-kxKo6PWX4Z8upUyz9Aj0Vc28HhVmziQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to