#25997: Editing ForeignKey in admin popup causes incorrect escaping for uuid
field
-------------------------------+--------------------
Reporter: zachborboa | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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:
1. Create new project using python3
$ mkvirtualenv --python=$(which python3) myproject && cd myproject
$ django-admin startproject mysite && cd mysite
$ python manage.py startapp polls
2. Add polls to INSTALLED_APPS
3. Set polls/models.py
{{{#!python
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)
}}}
4. Set polls/admin.py
{{{#!python
from django.contrib import admin
from .models import Choice
from .models import Question
admin.site.register(Choice)
admin.site.register(Question)
}}}
5. Go to the admin add page for Choice
http://127.0.0.1:8000/admin/polls/choice/add/
6. 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.
7. Click the pencil edit button next to the Question label. In the new
popup window, click save. The uuid is no longer correctly displayed.
--
Ticket URL: <https://code.djangoproject.com/ticket/25997>
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/053.1e06627577ae603fd6b7b61c745b9abb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.