RecursionError: maximum recursion depth exceeded (pythonanywhere)

I've deployed a DRF project on pythonanywhere. I have several endpoints like products, collections, carts and ...

products and collection endpoints are ok. but it's not ok when I try to visit other endpoints like carts (all endpoints work in local)

2022-09-04 07:36:45,190: Error running WSGI application
2022-09-04 07:36:45,210: RecursionError: maximum recursion depth exceeded
2022-09-04 07:36:45,211:   File "/home/piriecommerce/.virtualenvs/myenv/lib/python3.9/site- 
packages/django/core/handlers/", line 131, in __call__
2022-09-04 07:36:45,211:     response = self.get_response(request)

class WSGIHandler(base.BaseHandler):
request_class = WSGIRequest

def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

def __call__(self, environ, start_response):
    signals.request_started.send(sender=self.__class__, environ=environ)
    request = self.request_class(environ)
    response = self.get_response(request)

    response._handler_class = self.__class__

    status = "%d %s" % (response.status_code, response.reason_phrase)
    response_headers = [
        *(("Set-Cookie", c.output(header="")) for c in response.cookies.values()),
    start_response(status, response_headers)
    if getattr(response, "file_to_stream", None) is not None and environ.get(
        # If `wsgi.file_wrapper` is used the WSGI server does not call
        # .close on the response, but on the file wrapper. Patch it to use
        # response.close instead which takes care of closing all files.
        response.file_to_stream.close = response.close
        response = environ["wsgi.file_wrapper"](
            response.file_to_stream, response.block_size
    return response
Back to Top