I am aware that I can specify any model's primary key by adding that kwarg
to a field within the model. I currently do this with most my models, using
UUIDField as the primary key:
class MyModel(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
# Insert rest of fields here
I like UUID for my PK's a lot (I don't want someone able to simply guess at
what my PK's are because they are just auto-incrementing integers - if
there is a 74 then its obvious that there is 1-73 as IDs), and it is very
handy to be able to specify this and overwrite the default AutoField within
each model.
What I would like is for someway to configure this behavior globally in the
settings.py project settings. If I desire to change it globally like this,
I think it reasonable to have a finite list of viable replacements, such as
UUIDField, to replace it, as the main constraint is uniqueness within the
DB Table for PK's.
Setting this would make it so I do not have to specify an id field for
every model to use the UUID PK that I want to use, which would be
convenient for me. I would also like it to affect the Join Tables created
by Many to Many Fields
--
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/ce3768ba-61ee-4e3e-96ac-9f869737c9ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.