#24377: UUIDField as primary key breaks inline admins
---------------------------------+-----------------------
Reporter: yoyoma | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.8alpha1
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------
{{{
class Parent(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
name = models.CharField(max_length=255)
class Child(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
name = models.CharField(max_length=255)
parent = models.ForeignKey(Parent)
}}}
{{{
class ChildInline(admin.TabularInline):
model = Child
class ParentAdmin(admin.ModelAdmin):
inlines = [ChildInline]
}}}
== Given the above models and admins: ==
If you attempt to create a {{{Parent}}}, all the {{{Child}}} fields will
contain {{{This field is required.}}} errors.
I think the issue here is {{{default=uuid.uuid4}}}, and I think what's
happening is, since the {{{uuid4}}} value provided to the {{{uuid}}} field
on page load will differ from the {{{uuid4}}} value provided when the form
is posted, Django is considering the state as having been changed
(resulting in validation).
I've set the Component as Forms, since this is most likely a form issue,
rather than being admin-specific. I've also set the Severity to Release
Blocker, since the last {{{UUIDField}}} issue I encountered was marked as
such, and since this sort of breaks the (probably) most common usage of
{{{UUIDField}}}. Please let me know if I should not set the Severity in
the future.
--
Ticket URL: <https://code.djangoproject.com/ticket/24377>
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/049.56dba92b3cfaf79535efcb66d5111fca%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.