Opened 6 years ago
Closed 6 years ago
#29869 closed Cleanup/optimization (fixed)
UUIDField.to_python() should convert int values
Reported by: | thenewguy | Owned by: | Sanyam Khurana |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It would be handy if UUIDField.to_python() could handle integer values. This has practical application when using generic foreign keys in a project that mixes auto fields and uuid primary keys. The generic id field could be set to a BigIntegerField and then could point to uuid or integer primary keys
https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L2320
Change History (7)
comment:1 by , 6 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Summary: | UUIDField to_python should convert int values → UUIDField.to_python() should convert int values |
Type: | Uncategorized → Cleanup/optimization |
comment:3 by , 6 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Accepting on the basis that I could see it being useful when migrating a project from sequence based to uuid primary keys.
comment:4 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 6 years ago
Has patch: | set |
---|
I've added a patch for this here: https://github.com/django/django/pull/10557
comment:6 by , 6 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Marking as RFC given I'm not sure this is worth a mention in the release notes.
How would the conversion work?