Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ormar example raises AttributeError when queried #73

Closed
johnthagen opened this issue Apr 22, 2021 · 2 comments
Closed

ormar example raises AttributeError when queried #73

johnthagen opened this issue Apr 22, 2021 · 2 comments

Comments

@johnthagen
Copy link
Contributor

johnthagen commented Apr 22, 2021

I tried running the ormar example as is and it did not work:

# OS: macOS

(venv) $ python --version
Python 3.9.1

(venv) $ pip freeze
aiosqlite==0.17.0
click==7.1.2
databases==0.4.1
Faker==8.1.0
fastapi==0.63.0
fastapi-pagination==0.7.0
h11==0.12.0
ormar==0.10.4
pydantic==1.8
python-dateutil==2.8.1
six==1.15.0
SQLAlchemy==1.3.23
starlette==0.13.6
text-unidecode==1.3
typing-extensions==3.7.4.3
uvicorn==0.13.4

(venv) $ uvicorn pagination_ormar:app --reload
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [60370] using statreload
INFO:     Started server process [60372]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:58059 - "GET /docs HTTP/1.1" 200 OK
INFO:     127.0.0.1:58059 - "GET /openapi.json HTTP/1.1" 200 OK
INFO:     127.0.0.1:58059 - "GET /docs HTTP/1.1" 200 OK
INFO:     127.0.0.1:58059 - "GET /openapi.json HTTP/1.1" 200 OK
INFO:     127.0.0.1:58059 - "GET /users/limit-offset?limit=50&offset=0 HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "./venv/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "./venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/fastapi/applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "./venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "./venv/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "./venv/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "./venv/lib/python3.9/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "./venv/lib/python3.9/site-packages/fastapi/routing.py", line 209, in app
    response_data = await serialize_response(
  File "./venv/lib/python3.9/site-packages/fastapi/routing.py", line 109, in serialize_response
    response_content = _prepare_response_content(
  File "./venv/lib/python3.9/site-packages/fastapi/routing.py", line 66, in _prepare_response_content
    return res.dict(
  File "pydantic/main.py", line 495, in pydantic.main.BaseModel.dict
  File "pydantic/main.py", line 859, in _iter
  File "pydantic/main.py", line 800, in pydantic.main.BaseModel._get_value
  File "pydantic/main.py", line 785, in genexpr
  File "pydantic/main.py", line 749, in pydantic.main.BaseModel._get_value
  File "./venv/lib/python3.9/site-packages/ormar/models/newbasemodel.py", line 700, in dict
    pk_only = object.__getattribute__(self, "__pk_only__")
AttributeError: __pk_only__
INFO:     127.0.0.1:58066 - "GET /users/default?page=0&size=50 HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "./venv/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "./venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/fastapi/applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "./venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "./venv/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "./venv/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "./venv/lib/python3.9/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "./venv/lib/python3.9/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "./venv/lib/python3.9/site-packages/fastapi/routing.py", line 209, in app
    response_data = await serialize_response(
  File "./venv/lib/python3.9/site-packages/fastapi/routing.py", line 109, in serialize_response
    response_content = _prepare_response_content(
  File "./venv/lib/python3.9/site-packages/fastapi/routing.py", line 66, in _prepare_response_content
    return res.dict(
  File "pydantic/main.py", line 495, in pydantic.main.BaseModel.dict
  File "pydantic/main.py", line 859, in _iter
  File "pydantic/main.py", line 800, in pydantic.main.BaseModel._get_value
  File "pydantic/main.py", line 785, in genexpr
  File "pydantic/main.py", line 749, in pydantic.main.BaseModel._get_value
  File "./venv/lib/python3.9/site-packages/ormar/models/newbasemodel.py", line 700, in dict
    pk_only = object.__getattribute__(self, "__pk_only__")
AttributeError: __pk_only__

CC @collerek

collerek added a commit to collerek/ormar that referenced this issue Apr 23, 2021
@collerek
Copy link
Contributor

Fixed in 0.10.5, @uriyyo can you please bum required ormar version >=0.10.5? And after that (and maybe additional check) you can close the issue ;)

Thanks!

uriyyo added a commit that referenced this issue Apr 25, 2021
@uriyyo
Copy link
Owner

uriyyo commented Apr 25, 2021

Hi @collerek,

Thanks for a quick fix. Issue has been resolved 🙂

@uriyyo uriyyo closed this as completed Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants