please, I need help with that "request" object that is making me despair...
I read that theoretically "request" in views is an "HttpRequest" object but I have a script which needs to call a views.py function, which needs to use that "request" so receive it as argument.
Then I tried to import that object in my script in so many modes, but it seems always "not be the same"
and I get annoying errors as:
"'HttpRequest' object has no attribute 'session'"
Is there another way to use "request" object in a view's function avoiding to pass as argument?
Something like this:?
request = ??
form = fooform
bar = request.session['foo']
'form' = form
'bar' = bar
return render(request, "foo.html", context)
I know that's not elegant, but I'm still learning and I really don't need for this program an elegant solution.
Thanks in advance
What I have tried:
I tried to import that misterious object in so many modes:
from django.http import request
from django.http import HttpRequest
request = HttpRequest()
from urllib import request
from urllib import HttpRequest