I still have the problem with a primary key containing a '#'.
But there may be other problematic characters.
RFC 1738 (URL) says :
> Reserved:
>
> Many URL schemes reserve certain characters for a special meaning:
> their appearance in the scheme-specific part of the URL has a
> designated semantics. If the character corresponding to an octet is
> reserved in a scheme, the octet must be encoded. The characters ";",
> "/", "?", ":", "@", "=" and "&" are the characters which may be
> reserved for special meaning within a scheme. No other characters may
> be reserved within a scheme.
Possible (safe) solution : in django.contrib.admin.views.main.quote, change
{{{
#!python
if c in ':/_':
}}}
to
{{{
#!python
if c in ':/_#?@=&':
}}}
and adapt the docstring.
Actually, i think that HTTP doesn't have a special meaning for '@', '=', '&' in the main part of the URL. So maybe they don't need to be escaped.