~petersanchez/django-impersonate#44: 
Accept UUID for User pk

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')),
Status
REPORTED
Submitter
bitbucket:Eric K.
Assigned to
No-one
Submitted
7 years ago
Updated
4 years ago
Labels
No labels applied.

bitbucket:Eric K. 7 years ago · edit

No Message

bitbucket:Peter Sanchez 7 years ago · edit

Thank you! I'll include this in 1.2. I think it's a simple regex change.

bitbucket:Christopher Bailey 5 years ago · edit

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 a str before being stored on the session as this still works:

u = User.objects.get(pk="ffffbc6b-0703-48af-8f76-c418ec608933")
Register here or Log in to comment, or comment via email.