Home > OS >  Django, how to get current request method? request is not working in my views.py
Django, how to get current request method? request is not working in my views.py

Time:01-24

I'm new to Django. I'm trying to get my current request method to see if it is "POST" method.

But I got error message says: Unresolved reference 'request'

I tried to import request, but I don't know which one is correct.

import choices

Thanks for your help!

Kind regards,

Xi

CodePudding user response:

Have a look at the following:

    import requests
    response = requests.post(url, data=body, headers=headers)

CodePudding user response:

My bad, I shouldn't put the request as a variable in a class, request is supposed to work in the function

  • Related