Created
July 10, 2019 20:08
-
-
Save gregschmit/b1787d9f4d0b4b6c9a18f15608d15159 to your computer and use it in GitHub Desktop.
django_profiler.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from django.core.urlresolvers import resolve | |
from django.test import RequestFactory | |
def profile_request(url='/', username='gschmit'): | |
# perform a GET for the profiler | |
u = User.objects.get(username=username) | |
rf = RequestFactory() | |
request = rf.get(url) | |
request.user = u | |
match = resolve(url) | |
response = match.func(request) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment