[Django] #30006: Wrong UUID serialization in inline admin when used as a 1to1Field primary key of a UUID primary key.

3 views
Skip to first unread message

Django

unread,
Dec 4, 2018, 1:42:17 AM12/4/18
to django-...@googlegroups.com
#30006: Wrong UUID serialization in inline admin when used as a 1to1Field primary
key of a UUID primary key.
-----------------------------------------+------------------------
Reporter: Gerhut | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
Sorry for the confusing title, I create a reproducing
[https://github.com/Gerhut/django-inline-admin-bug repo] on GitHub.

Key code as follows:

models.py


{{{
class Room(models.Model):
id = models.UUIDField(default=uuid4, primary_key=True, editable=False)
name = models.TextField()

def __str__(self):
return self.name


class Teacher(models.Model):
room = models.OneToOneField(Room, on_delete=models.CASCADE,
primary_key=True)
name = models.TextField()

def __str__(self):
return self.name


class Student(models.Model):
id = models.UUIDField(default=uuid4, primary_key=True, editable=False)
teacher = models.ForeignKey(Teacher, on_delete=models.CASCADE)
name = models.TextField()

def __str__(self):
return self.name
}}}

admin.py
{{{
from .models import Room, Teacher, Student


@admin.register(Room)
class RoomAdmin(admin.ModelAdmin):
pass


@admin.register(Teacher)
class TeacherAdmin(admin.ModelAdmin):
class StudentInline(admin.TabularInline):
model = Student

inlines = [StudentInline]
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30006>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 4, 2018, 2:46:09 AM12/4/18
to django-...@googlegroups.com
#30006: Wrong UUID serialization in inline admin when used as a 1to1Field primary
key of a UUID primary key.
-------------------------------+--------------------------------------

Reporter: Gerhut | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.1
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 Gerhut):

Found a workaround: add {{{readonly_fields = ('teachers',)}}} to student
inline works.

--
Ticket URL: <https://code.djangoproject.com/ticket/30006#comment:1>

Django

unread,
Dec 4, 2018, 4:39:29 AM12/4/18
to django-...@googlegroups.com
#30006: Wrong UUID serialization in inline admin when used as a 1to1Field primary
key of a UUID primary key.
-------------------------------+--------------------------------------

Reporter: Gerhut | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.1
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 Gerhut):

{{{
>>> from app.models import *
>>> Teacher.objects.last().room_id
UUID('38c7b7f8-1006-467c-809b-e95546dcc58e')
>>> Student.objects.last().teacher_id
'38c7b7f81006467c809be95546dcc58e'
}}}

They are all UUIDs

--
Ticket URL: <https://code.djangoproject.com/ticket/30006#comment:2>

Django

unread,
Dec 4, 2018, 5:17:59 AM12/4/18
to django-...@googlegroups.com
#30006: Wrong UUID serialization in inline admin when used as a 1to1Field primary
key of a UUID primary key.
-------------------------------------+-------------------------------------
Reporter: Gerhut | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* status: new => closed
* component: contrib.admin => Database layer (models, ORM)
* resolution: => duplicate


Comment:

Duplicate of #27595 which will be fixed in Django 2.2.

--
Ticket URL: <https://code.djangoproject.com/ticket/30006#comment:3>

Reply all
Reply to author
Forward
0 new messages