You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm running Django under ASGI and basic api routes are working fine. But when I follow the django-ninja documentation for an api route using a Schema response, I get this error:
class PersonSchema(ModelSchema):
class Config:
model = User
model_fields = ["id", "username"]
@api.get("/people/", response=List[PersonSchema])
def people(request):
return User.objects.all()
Versions (please complete the following information):
Python version: [3.10, 3.11, 3.12]
Django version: [4.x, 5.x]
Django-Ninja version: [1.1.0, 1.0, 0.22.0]
Pydantic version: [-na-]
Traceback
024-05-16 10:36:25 Traceback (most recent call last):
2024-05-16 10:36:25 File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 518, in thread_handler
2024-05-16 10:36:25 raise exc_info[1]
2024-05-16 10:36:25 File "/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py", line 42, in inner
2024-05-16 10:36:25 response = await get_response(request)
2024-05-16 10:36:25 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-16 10:36:25 File "/usr/local/lib/python3.12/site-packages/django/utils/deprecation.py", line 152, in __acall__
2024-05-16 10:36:25 response = await sync_to_async(
2024-05-16 10:36:25 ^^^^^^^^^^^^^^^^^^^^
2024-05-16 10:36:25 File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 468, in __call__
2024-05-16 10:36:25 ret = await asyncio.shield(exec_coro)
2024-05-16 10:36:25 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-16 10:36:25 File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
2024-05-16 10:36:25 result = self.fn(*self.args, **self.kwargs)
2024-05-16 10:36:25 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-16 10:36:25 File "/usr/local/lib/python3.12/site-packages/asgiref/sync.py", line 522, in thread_handler
2024-05-16 10:36:25 return func(*args, **kwargs)
2024-05-16 10:36:25 ^^^^^^^^^^^^^^^^^^^^^
2024-05-16 10:36:25 File "/usr/local/lib/python3.12/site-packages/django/middleware/common.py", line 107, in process_response
2024-05-16 10:36:25 if response.status_code == 404 and self.should_redirect_with_slash(request):
2024-05-16 10:36:25 ^^^^^^^^^^^^^^^^^^^^
2024-05-16 10:36:25 AttributeError: 'QuerySet' object has no attribute 'status_code'
Other traceback
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm running Django under ASGI and basic api routes are working fine. But when I follow the
django-ninja
documentation for an api route using a Schema response, I get this error:'QuerySet' object has no attribute 'status_code'
requirements.txt
Route definition
Versions (please complete the following information):
Traceback
Other traceback
The text was updated successfully, but these errors were encountered: