﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33894	Underscore in CharField as Primary Key breaks related link displayed by admin's ForeignRawIdWidget	Robert-Lebedeu	nobody	"I understand that in order to handle primary keys that may contain special characters, the usage of {{{django.contrib.admin.utils.quote}}}  is needed.

I see that the method {{{label_and_url_for_value(...)}}} of {{{ForeignKeyRawIdWidget}}} doesn't escape the primary key when calculating the related object URL.

I suppose the solution to this problem would be adding {{{args=quote(obj.pk),}}} to the {{{reverse}}} call.

Small example to re-create the BUG:
1. Create following models:
{{{
from django.db import models

class ModelA(models.Model):
    id = models.CharField(max_length=100, primary_key=True)

class ModelB(models.Model):
    a_model = models.ForeignKey(ModelA)
}}}
2. Enable and register both models to the admin
3. Add {{{a_model}}} field to {{{raw_id_fields}}} of ModelBAdmin
4. Create one instance per model
5. Try using related link displayed by {{{ForeignKeyRawIdWidget}}} and see how it doesn't work.

"	Bug	closed	contrib.admin	dev	Normal	duplicate	Underscore, CharField, Primary Key, link, reverse	lorenzo.morandini@…	Unreviewed	0	0	0	0	0	0
