﻿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
36482	Admin renders complex PKs incorrectly	David Sanders	David Sanders	"Admin creates links to edit/history/etc pages by rendering the PK directly as a string - either explicitly in Python or implicitly in one of the templates.

However when the instance is retrieved in `get_object()` it uses `field.to_python(value)` like so: https://github.com/django/django/blob/a3882876927a819ca982ea61353945e9d86f3659/django/contrib/admin/options.py#L886

This creates an asymmetrical serialisation-deserialisation process which, while is fine for integers, will fail for things more complex.

The correct serialisation of pk would be the inverse of `to_python()`: `field.value_to_string(obj)`.

Note this is related to #35953: The fix for this would also be useful to get composite PKs working - at least for rendering the PK.

I noticed this while trying out `DateTimeRangeField()` as part of the PK for temporal models as the `valid_time` – this field type uses specific json serialisation which is quite verbose in the URL but works (have tested it will post proposed patch in a draft PR)"	Bug	assigned	contrib.admin	dev	Normal				Accepted	1	0	1	0	0	0
