New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create (or change) a model to use UUID/non-integer for its primary key #448
Labels
Comments
Just to note – primary keys are read-only: https://docs.djangoproject.com/en/4.2/ref/models/fields/#primary-key
|
Ahh. Good point @laymonage - I'll fix that. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
We often get bugs raised for models that use a non-integer primary key.
This creates a few issues with our code assumptions
Proposal
Assuming we can use a migration to modify existing models, that would be best as it avoids trying to think of new example data.
breads.Country
- Change to a non-integer primary key of a two letter string. E.g. 'AU', that's set on creation of any new entries, but will not be editable (read only but visible in the UI on edit).breads.BreadIngredient
- Change to a non-integer primary key that's an auto-generated UUID (or BreadType). Not visible in the UI.This way we are only changing models in one app and have a cross-section of UI interaction (choosers, snippet listing, history etc).
Related issues & PRs
Many are closed, but retesting this is often tricky and it would be great if we had a model ready to go. Plus, if problems like these are more visible we may find them earlier.
ModelViewSet
to be used for models with non-integer primary keys wagtail#10900The text was updated successfully, but these errors were encountered: