0

in my django project, I want the function that generates the returned result not to process the other request before it ends. How can I provide this?

views.py

def orderresult(request):
    
    
    if request.method == 'POST':
        username =  request.POST["username"]
        order =  request.POST["order"]
        doubleResult = ResultsFormView(order,username).resultview() # ====> Async await function
        result = doubleResult[0]
        boolresult = doubleResult[1]
        context = {
            "result" : result,
            "boolresult" : boolresult
            
        }
        return render(request, 'npages/result.html', context=context)

I tried something like this but it doesn't work.

async def orderresult(request):
    
    
    if request.method == 'POST':
        username =  request.POST["username"]
        order =  request.POST["order"]
        doubleResult = await ResultsFormView(order,username).resultview() # ====> Async await function
        result = doubleResult[0]
        boolresult = doubleResult[1]
        context = {
            "result" : result,
            "boolresult" : boolresult
            
        }
        return render(request, 'npages/result.html', context=context)
3
  • have you seen it: docs.djangoproject.com/en/4.0/topics/async ? Jul 23, 2022 at 13:49
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Jul 23, 2022 at 14:52
  • Mixing async code in Django should be possible while using async views - try the mentioned by @MaximDanilov link, it should work. Jul 23, 2022 at 17:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.