I need this 10-digit unique ID for every model instance so users can easily 
search up a specific model instance.  It will be publicly displayed on the 
website, unlike a primary key which is usually hidden

On Sunday, October 22, 2017 at 1:31:23 PM UTC-4, Avraham Serour wrote:
>
> The database usually handles this and you don't need to worry, there are 
> many corner cases and DB systems are able to handle them
>
> But they won't look like whatever format you would like, usually it is 
> just a number
>
> Why do you need the IDs to look like that?
>
> On Oct 22, 2017 6:53 PM, "Jack Zhang" <[email protected] <javascript:>> 
> wrote:
>
>> Let's say I have a model called 'Dogs'.  Users can create instances of 
>> Dogs.  For every Dogs instance that is created, I want to assign a globally 
>> unique ID to it.  The ID will be 3 capitalized letters followed by 7 
>> numbers.  E.g. ABC1234567, POZ2930193
>>
>> What is the easiest way to go about doing this?  I looked into UUID but 
>> it generates a longer string.  Keep in mind that the ID must be globally 
>> unique - so after one has been created, it should not be created again.
>>
>> Thanks.
>>
>> -- 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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/0cd8e33c-8c92-471c-9c36-ac82749750b4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0cd8e33c-8c92-471c-9c36-ac82749750b4%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 users" 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e22c52fe-ff85-4d26-806b-4de9bb12e7a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to