#34653 closed Bug (invalid)

Django (4.2.2) doesn't handle unicode characters in labels of choices

Reported by: Stefanos Owned by: nobody
Component: Migrations Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

[In case it doesn't render correctly, the apostrophe in choices is unicode character U+2019]
Consider the following model:

class Marks(models.Model):
    CHOICES = [("apostrophe", "’")]

    marks = models.CharField(max_length=10, choices=CHOICES)

every time that django-admin makemigrations is called a new migration is created, because the autodetector detects that the field has changed (old_field.choices, new_field.choices):

([('apostrophe', '`')], [('apostrophe', '’')])

Change History (1)

comment:1 by David Sanders, 18 months ago

Resolution: invalid
Status: newclosed

Sorry I can't reproduce this on main, here's the migration generated from the model in the description:

# Generated by Django 5.0.dev20230612063128 on 2023-06-14 03:03

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Marks",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "marks",
                    models.CharField(choices=[("apostrophe", "’")], max_length=10),
                ),
            ],
        ),
    ]
Note: See TracTickets for help on using tickets.
Back to Top