Is there a way to get the request
in the Django shell (./manage.py shell
)?
Here is an example on how I currently do it which will make the question more clear.
File: views.py
import ipdb
def index(request):
ipdb.set_trace()
#method code ...
return render(...)
What ipdb.set_trace()
does is open a ipython shell and gives me access to all the objects available at that point in the method index
including the request
.
For example, i can check request.user.is_anonymous()
.
However, I can't convert that to unit tests because the way of getting there is to "human depended", so I'm looking for a way to achieve the similar result purely from the Django shell.