Hello,
Thank your for your reply. I'm not using Python 2. I have attached the traceback as is emailed by Django to the Admin.
Traceback:
File "/home/user/api/env/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/user/api/env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/user/api/env/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/user/api/env/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "/home/user/api/env/lib/python3.6/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/home/user/api/env/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
505. response = self.handle_exception(exc)
File "/home/user/api/env/lib/python3.6/site-packages/rest_framework/views.py" in handle_exception
465. self.raise_uncaught_exception(exc)
File "/home/user/api/env/lib/python3.6/site-packages/rest_framework/views.py" in raise_uncaught_exception
476. raise exc
File "/home/user/api/env/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
502. response = handler(request, *args, **kwargs)
File "/usr/lib/python3.6/contextlib.py" in inner
52. return func(*args, **kwds)
File "/home/user/api/project/cashless/views/order.py" in post
143. order.save()
File "/home/user/api/project/payment_gateway/models.py" in save
79. if ref_number not in transactions:
Exception Type: TypeError at [ENDPOINT]
Exception Value: argument of type 'QuerySet' is not iterable
I have did further testing and determined that my earlier hypothesis of select_for_update is not responsible for this error. The error persisted even after having removed that call.
I also figured that it the TypeError was mapping some internal system call and I did further testing and I realized the error is a TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.
That save happens inside of an atomic transaction. There are a couple of other select statements that are executed before this one (also inside the transaction). Though, I haven't been able to figure out what's wrong though.
Any leads would be appreciated.
Thank you.