Since Django 1.8 it is possible to define UUID fields, even for primary keys.
Doing the following change possibly is enough?
# from
url(r'^(?P<uid>\d+)/$', 'impersonate', name='impersonate-start'),
# to
url(r'^(?P<uid>[0-9A-Fa-f-]+)/$', 'impersonate', name='impersonate-start'),
To circumvent this issue, I added the following URL resolver before the line includes impersonate.urls
:
url(r'^imp_uuid/(?P<uid>[0-9A-Fa-f-]+)$', 'impersonate.views.impersonate',
name='impersonate-start-uuid'),
url(r'^imp/', include('impersonate.urls')),
No Message
Thank you! I'll include this in 1.2. I think it's a simple regex change.
This is still not resolved if you are using a Session backend that is JSON based (like redis). UUIDs are not JSON serializable.
If the
pk
is a UUID, it should be cast to astr
before being stored on the session as this still works:u = User.objects.get(pk="ffffbc6b-0703-48af-8f76-c418ec608933")