Uri, I would definitely suggest using an actual UUID rather than rolling your 
own ad-hoc UUID implementation, even if your database does not support a native 
UUID type.

Brian, there is some work ongoing that should make this possible. We will add a 
setting to control the type of the auto-created primary key type. Initially it 
will be restricted to AutoField subclasses only, but the intent is to make 
UUIDFields work with this as well. 

The first bit of work is here: https://github.com/django/django/pull/13179

Tom

> On 14 Nov 2020, at 16:54, אורי <u...@speedy.net> wrote:
> 
> 
> Hi Brian,
> 
> In Speedy Net we use a randomly generated string of digits, either 15 digits 
> or 20 digits, as a primary key in all our models. We never use 
> auto-incrementing integers as primary keys. You can take a look at our 
> implementation, especially class BaseModel which is the base class for all 
> our models, and class TimeStampedModel (most of our models inherit from 
> TimeStampedModel):
> 
> https://github.com/speedy-net/speedy-net/blob/master/speedy/core/base/models.py
> 
> We also defined managers with querysets in which bulk_create() and delete() 
> are disabled.
> 
> Uri Rodberg, Speedy Net.
> אורי
> u...@speedy.net
> 
> 
>> On Sat, Nov 14, 2020 at 6:32 PM Brian Carter <brianrcarte...@gmail.com> 
>> wrote:
>> Feature Request:
>> 
>> I like to use the UUIDField as the primary key in my models, and I think it 
>> would be nice to have django expose a setting in the settings.py to override 
>> the default primary key on models. 
>> 
>> Currently, if I don’t specify a field as the primary key, Django 
>> automatically uses an AutoField (auto-incrementing integer). I’d like to be 
>> able to automatically use a UUID field, but then still be overridden in a 
>> specific model if I specify a different primary key.
>> 
>> Brian Carter
>> brianrcarte...@gmail.com
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers  (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-developers+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/EAF4690E-C862-4C68-A7DD-C2979F19BC3C%40gmail.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/CABD5YeFqeRfd6%2BMuMdzsagvjKdNu-iEDND-omuePX9TEw9TGTw%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/833A8A9F-14A2-4C37-8780-778F983C4B9D%40tomforb.es.

Reply via email to