Quickly Impersonate Another User In Your Django Project
I've created or worked on so many Django projects in the last 4 years that I find myself completely forgetting a project or client all together. It's sort of funny. Anyways...
Too many times I've run into a situation where I, as an admin, need to impersonate another user on the system so I can verify a bug or issue that the user is experiencing. Over the years I've thrown together some internal methods to easily accomplish this.
Well I finally got fed up with the process and decided to roll out a easily re-usable Django app to make it easy to do this for any Django project you may be working on.
Drum roll please...
OK, that wasn't as dramatic of an announcement as I'd hoped. In any case, you can clone django-impersonate on the BitBucket page for the app. It's also easily available via pip (pip install django-impersonate.)
The app has a few helpful methods out the gate. A few views to actually start the impersonation, end it, list users, and search users. The search is just a basic query filtering on the username, first & last names, and email addresses of all the system users.
A middleware is used to handle the request.user assignment if the right conditions are met. There are a few settings options to help give a little more control over the app and who is allowed to use it. It's a pretty simple and straight forward app in the end.
The app depends on you using the Django contrib auth and session apps (enabled by default in any new Django project.)
Instructions can be found in the projects README.txt.
Please report any issues via the project's page.
Click here to head to the django-impersonate project page...