Answer the question
In order to leave comments, you need to log in
How to call a function in Django?
How can I call a function in django if it has a request argument?
def A(request):
. . .
get = json.loads(request.body)
A() # TypeError: A() missing 1 required positional argument: 'request'
A(request) # AttributeError: module 'django.http.request' has no attribute 'body'
Answer the question
In order to leave comments, you need to log in
I'm wondering - before you ask a question, did you read at least some material on django? I doubt it, because such things are described in the first lesson / chapter !
Obviously, passing the request object to it.
How to do it?
B.1 Add an appropriate route for it in urls.py
B.2 Call it in a function that is specified in an existing route.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question