Open mathiasertl opened 2 months ago
Sharing a monkeypatch I used to suppress this behavior. The behavior of the uuid
converter has always been to return a UUID instance since Django 2.0. I don't really think it should behave differently in Django Ninja than the int
converter (i.e. returning str
instead of the actual type).
Add the following code to your settings.py
.
def monkeypatch_ninja_uuid_converter() -> None:
import importlib
import sys
import django.urls
module_name = "ninja.signature.utils"
sys.modules.pop(module_name, None)
original_register_converter = django.urls.register_converter
def fake_register_converter(*_: Any, **__: Any) -> None:
pass
django.urls.register_converter = fake_register_converter
importlib.import_module(module_name)
django.urls.register_converter = original_register_converter
monkeypatch_ninja_uuid_converter()
Describe the bug
When running
python -Wd ca/manage.py check
I get a deprecation warning (paths trimmed for privacy):django-ninja registers a converter called
uuid
, which is already registered by Django. Support for overriding a converter will be removed in Django 6.0. This converter is also problematic as it alters the behavior of views unrelated to django-ninja: A standard Django view using theuuid
converter will receive a different type of value depending on if django-ninja is used or not - this was also already raised in #280.From the looks of it, I think the converter can be safely removed. If not, it has to be renamed. Please advice on your preferred course of action, I'm happy to make a PR.
Versions (please complete the following information):