tags:

views:

33

answers:

1

Django by default makes a primary key field on each model named "id", with a type of AutoField. On my models, I'm overriding this to use a custom UUIDField as the primary key by using the "primary_key" attribute. I would also like the User model in django.contrib.auth to have a UUIDField as the primary key, but this doesn't seem to be possible without changing the User model source code.

Is there any recommended way to approach this problem?

+1  A: 

this doesn't seem to be possible without changing the User model source code.

Correct. Unless you are willing to change (or replace) User there isn't a way.

One (tenuous, hackish) way to do this would be to attach an UserProfile for each User instance. Each User should have exactly one UserProfile. You can then add your UUIDField to the profile. You will still have to do custom querying to translate from UUIDField to id.

If you don't like the name UserProfile you can rename it suitably. The key is that you have a one-to-one relationship to User.

Manoj Govindan
I figured that would be the case. Thanks.
Andrew