Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:45:27+00:00 2026-06-12T20:45:27+00:00

When I print a request object from a view function in views.py I get

  • 0

When I print a request object from a view function in views.py I get a dictionary-like django.core.handlers.wsgi.WSGIRequest object(inherits from django.http.HttpRequest). Printing this dictionary-like object from a view function returns a bunch of values, especially for the META key.

Now I’d like to call this same data from the manage.py shell of my project but handlers is not an attribute of django.core in the shell so I cannot get the django.core.handlers.wsgi.WSGIRequest object. Is there any way of getting the request object as in my view function but called from the manage.py shell?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:45:28+00:00Added an answer on June 12, 2026 at 8:45 pm

    Since your goal is to “replicate a request object and fiddle with it from the shell for introspection“, the easiest way to accomplish fiddling with the request object is to use a debugger.

    Copy paste the following into your view and reload it:

    import pdb; pdb.set_trace()
    

    Now reload the page pointing at that view & you can use PDB’s debugger commands to exec your stuff. For example, inside a view function you can use p request to print the value of request, and you can also execute standard python code:

    (Pdb) path = request.META['USERNAME']
    (Pdb) h p
    p expression
    Print the value of the expression.
    (Pdb) p path
    'Caspar'
    (Pdb) from foo.models import MyUser
    (Pdb) MyUser.objects.all()
    [<MyUser: Bob: 3.62810036125>, <MyUser: Tim: no rating>, <MyUser: Jim: 2.41014167534>, <MyUser: Rod: 1.35651839383>]
    

    Even better, install ipdb (pip install ipdb), which lets you use the much nicer IPython shell, with fancy colors and tab completion.

    Or, if you have no need for a debugger but just want an interactive console, install IPython (pip install ipython) and use the following snippet:

    import IPython; IPython.embed()
    

    Note that IPython is a prerequisite for ipdb, so installing ipdb will also install IPython.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view in a Django 1.4 project: def index(request): print reverse('menus_index') latest_menu_list
In a Django view you can access the request.GET['variablename'] , so in your view
I have an object in my controller @data=<meta property=\og:url\ content=\<%=SITE_URL%><%=request.request_uri%>\ />.html_safe When I print
I'll get right to the point. This is what a browser request looks like
I need to read some values from the wsgi request before my flask app
I have the following view in my views.py: def MoveSucessfulEntries(request): if request.method == 'POST':
I try to get context object in IPubAfterTraversal hook from event @grok.subscribe(IPubAfterTraversal) def admin_language_negotiator(event):
I have this 'view'(django): def preview(request,war_id): set = stats.objects.filter(warval=get_object_or_404(war,pk=war_id)).order_by('date') for each in set: print(each.date)
I'm wondering why this code section prints out the following: print request.user.has_perm('bug_tracking.is_developer'): + str(request.user.has_perm('bug_tracking.is_developer'))
In our company,i got a request, print dhl & fedex express document on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.