Error is :ValueError: The view hadid.views.initiate_payment didn't return an HttpResponse object. It returned None instead.
Exception Location: C:\Users\Chaims music\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\handlers\base.py in _get_response, line 124
I am adding my def initiate_payment below
def initiate_payment(request):
if request.method == "GET":
return render(request, 'templates/pay.html')
try:
username = request.POST['username']
password = request.POST['password']
amount = int(request.POST['amount'])
user = authenticate(request, username=username, password=password)
if user is None:
raise ValueError
auth_login(request=request, user=user)
except:
return render(request, 'templates/pay.html', context={'error': 'Wrong Account Details or amount'})
transaction = Transaction.objects.create(made_by=user, amount=amount)
transaction.save()
This is just the initiate_payment where the error is coming from. please help i already tried similiar error
if any other file is needed let me know .
any help is appreciated .
Your view has to return a response, you return render(...) in your except block but you don’t return anything in the try block