django-ninja icon indicating copy to clipboard operation
django-ninja copied to clipboard

[BUG] Can't use parameter `keys`

Open will-emmerson opened this issue 2 years ago • 0 comments

Describe the bug I tried to add a parameter called keys like so:

@api.get("/getDeviceHistory", )
def get_device_history(request, deviceId, keys: str = "netDelta", rounding: bool = False):

But I get the following error:

Traceback (most recent call last):
  File "/home/will/saveeye/django_poc/venv/lib/python3.12/site-packages/ninja/operation.py", line 106, in run
    values = self._get_values(request, kw, temporal_response)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/will/saveeye/django_poc/venv/lib/python3.12/site-packages/ninja/operation.py", line 229, in _get_values
    values.update(data)
TypeError: 'str' object is not callable

I can see that it's probably conflicting with function keys in SupportsKeysAndGetItem but not sure what to do about it if anything.

Versions (please complete the following information):

  • Python version: 3.12
  • Django version: 5.0.1
  • Django-Ninja version: 1.1.0
  • Pydantic version: 2.5.3

will-emmerson avatar Mar 27 '24 11:03 will-emmerson