Giter Club home page Giter Club logo

Comments (8)

rubbieKelvin avatar rubbieKelvin commented on September 7, 2024

Show the error traceback

from django-ninja.

residentcode avatar residentcode commented on September 7, 2024
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.

fazeelghafoor avatar fazeelghafoor commented on September 7, 2024

@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.

residentcode avatar residentcode commented on September 7, 2024

@fazeelghafoor Thanks for your answer, I tried that but same error.
which django and python ver are you using?

from django-ninja.

fazeelghafoor avatar fazeelghafoor commented on September 7, 2024

@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.

residentcode avatar residentcode commented on September 7, 2024

@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.

residentcode avatar residentcode commented on September 7, 2024

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.

residentcode avatar residentcode commented on September 7, 2024

My mistake Sorry I just included a different api.urls, solved.

from django-ninja.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.