#23617: The new UUID field does not allow to automatically generate a UUID on
save
-------------------------------------+-------------------------------------
Reporter: thedrow | Owner: zedr
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by akaariai):
I recall presenting an alternate way to handle this. The original idea is
probably in the PR for the UUID field.
The idea was that we add a new method to fields, something like
get_value_on_save(). If the field implements this method, and you are
saving an instance with pk=None to the database, then the
get_value_on_save() method would be called. Thus, when UUIDField's value
is None, then a new UUID would be generated.
This would be a better solution than what we have currently for two
reasons:
- This would allow adding an UUIDField to models in migrations (the same
default value wouldn't be used for every instance)
- Model(uuid_pk=None).save() would save with an autogenerated UUID
value, same with instance.pk = None; insance.save()
--
Ticket URL: <https://code.djangoproject.com/ticket/23617#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.cc941878f922d9bd44368ab542e943b8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.