#25997 closed Bug (fixed)
Editing ForeignKey in admin popup causes incorrect escaping for uuid field
Reported by: | Zach Borboa | Owned by: | Sasha Gaevsky |
---|---|---|---|
Component: | contrib.admin | Version: | 1.9 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Editing and saving a model's foreign key causes the related field to display incorrectly.
Displays something like "b71658a1\u002Df845\u002D4a44\u002D8085\u002D03034580ac72"
instead of "b71658a1-f845-4a44-8085-03034580ac72"
Screenshot: https://i.imgur.com/Q5lrfV2.png
Reproduce:
- Create new project using python3
$ mkvirtualenv --python=$(which python3) myproject && cd myproject
$ django-admin startproject mysite && cd mysite
$ python manage.py startapp polls
- Add polls to INSTALLED_APPS
- Set polls/models.py
import uuid from django.db import models class Question(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) question_text = models.CharField(max_length=200) def __str__(self): return str(self.id) class Choice(models.Model): question = models.ForeignKey(Question) choice_text = models.CharField(max_length=200)
- Set polls/admin.py
from django.contrib import admin from .models import Choice from .models import Question admin.site.register(Choice) admin.site.register(Question)
- Go to the admin add page for Choice http://127.0.0.1:8000/admin/polls/choice/add/
- Click the plus sign ("+") next to the "Question:" label. Enter question text (like "test") and click save. The uuid is correctly displayed in the Question select box.
- Click the pencil edit button next to the Question label. In the new popup window, click save. The uuid is no longer correctly displayed.
Change History (11)
follow-up: 3 comment:1 by , 9 years ago
Component: | Uncategorized → contrib.admin |
---|---|
Severity: | Normal → Release blocker |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:2 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 9 years ago
Replying to timgraham:
Regression in 1.9 bisected to 845817b039fc059955bb1eafa5fd78565a49159d.
Just wondering if you tested in master branch because I suspect there could be related issue with UUID field.
follow-up: 5 comment:4 by , 9 years ago
There's another regression when closing the popup on master if that's what you ran into. It's tracked in comment:6:ticket:25165
comment:5 by , 9 years ago
Replying to timgraham:
There's another regression when closing the popup on master if that's what you ran into. It's tracked in comment:6:ticket:25165
Yes, that's exactly it.
Will it be fixed in terms of 25165 or new ticket will be opened?
Regression in 1.9 bisected to 845817b039fc059955bb1eafa5fd78565a49159d.