• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

로그인 후 list.html 로 전환 안되고 에러

23.03.20 21:26 작성 조회수 242

0

AttributeError

AttributeError: 'Cursor' object has no attribute 'count'

Traceback (most recent call last)

  • File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 2551, in __call__

    return self.wsgi_app(environ, start_response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 2531, in wsgi_app

    response = self.handle_exception(e)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  • File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 2528, in wsgi_app

    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 1825, in full_dispatch_request

    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 1823, in full_dispatch_request

    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  • File "C:\Users\hongbh\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 1799, in dispatch_request

    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  • File "D:\PM_WebService\main\member.py", line 23, in member_join

    cnt = members.find({"email": email}).count()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: 'Cursor' object has no attribute 'count'

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

  • dump() shows all variables in the frame

  • dump(obj) dumps all that's known about the object

답변 1

답변을 작성해보세요.

0

발생한 오류는 강의에서 사용한 몽고디비 버전과 실제 사용하시는 버전이 달라서 생기는 문제입니다. 어떤 버전을 사용하시는지 모르겠지만

# 3.6
cnt = members.find({"email": email}).count()

# 3.7 >=
cnt = members.count_documents({"email": email})

 

위의 내용과 좀 더 자세한 정보는 몽고DB 공식사이트 문서도 한번 참고해보시면서 사용중이신 몽고 디비 버전에 맞는 함수를 호출하셔야 할 듯 합니다.

아래 사진의 빨간색 표시 버전으로 설치 하였습니다

--> 6.0.4

image

그럼 소스에서 위 버전으로 적용하려면 어떻게 해야 하나요? 제가 초보라서...

현재 첨부하신 소스를 설치하여 동일하게 따라하기 형식으로 구동하여 가입하기, 글쓰기 등등..

나머지는 되는데... list 만 안되고 있습니다.