Comments (8)
Show the error traceback
from django-ninja.
Environment:
Request Method: GET
Request URL: http://localhost:8000/api/v1/product/
Django Version: 5.0.7
Python Version: 3.12.0
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'product']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "D:\djangoninja\.venv\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "D:\djangoninja\.venv\Lib\site-packages\django\utils\deprecation.py", line 136, in __call__
response = self.process_response(request, response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\djangoninja\.venv\Lib\site-packages\django\middleware\clickjacking.py", line 27, in process_response
if response.get("X-Frame-Options") is not None:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\djangoninja\.venv\Lib\site-packages\django\db\models\query.py", line 635, in get
clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\djangoninja\.venv\Lib\site-packages\django\db\models\query.py", line 1476, in filter
return self._filter_or_exclude(False, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\djangoninja\.venv\Lib\site-packages\django\db\models\query.py", line 1494, in _filter_or_exclude
clone._filter_or_exclude_inplace(negate, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\djangoninja\.venv\Lib\site-packages\django\db\models\query.py", line 1501, in _filter_or_exclude_inplace
self._query.add_q(Q(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\djangoninja\.venv\Lib\site-packages\django\db\models\sql\query.py", line 1613, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\djangoninja\.venv\Lib\site-packages\django\db\models\sql\query.py", line 1645, in _add_q
child_clause, needed_inner = self.build_filter(
File "D:\djangoninja\.venv\Lib\site-packages\django\db\models\sql\query.py", line 1492, in build_filter
arg, value = filter_expr
^^^^^^^^^^
Exception Type: ValueError at /api/v1/product/
Exception Value: too many values to unpack (expected 2)
from django-ninja.
@residentcode I've tried replicating the error show in the traceback you have shared but I was not able to reproduce it. Instead I got another error which was resolved by removing title
field in CategorySchema
as this was not defined in the Category
model and the api endpoint /api/product/
returns the correct and expected respone.
from django-ninja.
@fazeelghafoor Thanks for your answer, I tried that but same error.
which django and python ver are you using?
from django-ninja.
@residentcode I am using Django==5.0.7
and Python==3.11.7
. Going through the sample code you have provided, I have noticed that you have named model Product
same as your app name. It is also mentioned in the following link that this causes some issue sometimes in Pycharm.
I wonder if you create a new app with different name, do you encounter the same error?
from django-ninja.
@fazeelghafoor I tried VS CODE and python 3.11 , whatever i do it is the same error "too many values to unpack (expected 2)",
very weird.
from django-ninja.
even simple function doesn't work, I think something wrong with clickjacking.py
@api.get('/test')
def get_text(request):
return "Hello world"
AttributeError at /api/v1/test/
'str' object has no attribute 'get'
Request Method: GET
Request URL: http://localhost:8000/api/v1/test/
Django Version: 5.0.7
Exception Type: AttributeError
Exception Value:
'str' object has no attribute 'get'
Exception Location: d:\pythonProject\djangoninja.venv11\Lib\site-packages\django\middleware\clickjacking.py, line 27, in process_response
Raised during: product.views.get_text
Python Executable: d:\pythonProject\djangoninja.venv11\Scripts\python.exe
Python Version: 3.11.4
from django-ninja.
My mistake Sorry I just included a different api.urls, solved.
from django-ninja.
Related Issues (20)
- [BUG] Running tests using Schema model generates warning
- [BUG] Awkward router behaviour when path is like '/{some_var}' HOT 1
- After adding the blacklist successfully, the token is still authenticated successfully HOT 1
- [BUG] Sync-only Authentication Callbacks not Working on Async Operations HOT 1
- [BUG] Mock Request Generated by Test Client Doesnโt Support auser()
- RealWorld Demo for Django Ninja HOT 2
- Is there a way to use swagger and redoc together? HOT 1
- Websocket please!
- Inconsistent Documentation Regarding Resolver
- Easy way to change behavior of `BodyModel`? HOT 2
- [BUG] Converter `uuid` is already registered - deprecated in django 6.0
- Make 'exclude_none' and other options easier to enable per router
- [BUG] Field serialized when using repr=False HOT 1
- How to create an alias for a field created via annotation HOT 2
- [BUG] model_dump defaults to `mode=python`
- How can I use resolve_<field> for async api?
- Mypy complaining about PatchDict HOT 1
- [Question] Unable to cache paginated queryset `PicklingError` HOT 4
- Recommend approach to expose generic error handling to the generated OpenAPI specification
- [DOC] guides/input/file-params/ should say "Django's Upload_ed_File..."
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-ninja.