3

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.

TheMeaningfulEngineer
  • 15,679
  • 27
  • 85
  • 143
  • 1
    You will have to build your own request object like in a django unit test. http://stackoverflow.com/questions/10277748/how-to-get-request-object-in-django-unit-testing – Jingo Sep 16 '13 at 09:25

0 Answers0