Hi James,
First of all thank you for all your detailed replies. You have a wealth of
knowledge.
I took your advice and chose the separated method. I decided to use 2
letters + 8 numbers because 3 letters can render results like 'SEX' and
'FUK'.
I think I got it right. Here is my code:
James,
I agree with you - after thinking about it for another day, your solution
would be the best.
Regards,
Andréas
2017-10-23 10:51 GMT+02:00 James Schneider :
>
>
> On Oct 22, 2017 9:29 AM, "Andréas Kühne"
> wrote:
>
> Hi,
>
> When you
On Oct 22, 2017 9:29 AM, "Andréas Kühne" wrote:
Hi,
When you say "globally unique" - I am supposing you mean within your
application?
What you need to do is set a field to be the primary key, see :
https://docs.djangoproject.com/en/1.11/topics/db/models/#
On Oct 22, 2017 4:36 PM, "Mark Phillips" wrote:
I thought python's uuid.uuid4 guaranteed a unique value. Am I missing
something?
Mark
>From a practical perspective, you are correct, uuid.uuid4() will create a
unique value every time. There is no guarantee, though,
On Oct 22, 2017 8:52 AM, "Jack Zhang" 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.
I thought python's uuid.uuid4 guaranteed a unique value. Am I missing
something?
Mark
On Sun, Oct 22, 2017 at 3:58 PM, James Schneider
wrote:
>
>
> On Oct 22, 2017 12:29 PM, "Andréas Kühne"
> wrote:
>
> Hi,
>
> I think you are correct with
On Oct 22, 2017 12:29 PM, "Andréas Kühne"
wrote:
Hi,
I think you are correct with your pseudocode - you can do a
Model.objects.filter(unique_code==random_code).count() - and then loop on
that. It should work.
I wouldn't do this, it can lead to a race condition
Hi,
I think you are correct with your pseudocode - you can do a
Model.objects.filter(unique_code==random_code).count() - and then loop on
that. It should work.
The reason why I thought you should use the signals is because thats how I
have done the same things in the past. However, you can just
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
Hi Andréas,
Yes, by globally unique I mean a unique 10-digit ID is assigned to every
model instance of 'Dogs' within my application. This ID will be shown
publicly on the website to allow easy search access to a specific model
instance.
I think you are right about creating a new field to
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"
Hi,
When you say "globally unique" - I am supposing you mean within your
application?
What you need to do is set a field to be the primary key, see :
https://docs.djangoproject.com/en/1.11/topics/db/models/#automatic-primary-key-fields
However - it would be simpler to use the standard primary
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
13 matches
Mail list logo