You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We often get bugs raised for models that use a non-integer primary key.
This creates a few issues with our code assumptions
Converting to a string for element ID usage or similar can have problems
Using some_instance.id will not work and needs to.be replaced with some_instance.pk
Assumptions about general ordering of thing in code can be false
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.
The primary key field is read-only. If you change the value of the primary key on an existing object and then save it, a new object will be created alongside the old one.
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: