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
In my Django project, I'm encountering a ConfigError when trying to register routes for a single instance of NinjaAPI. Despite only creating one API instance, the error suggests that multiple NinjaAPIs or TestClients are registered, requiring unique versioning or URL namespaces. This issue arises when including the API's URLs in the core.urls.py file.
Error:
Exception in thread django-main-thread:
Traceback (most recent call last):
...
ninja.errors.ConfigError: Looks like you created multiple NinjaAPIs or TestClients
To let ninja distinguish them you need to set either unique version or urls_namespace
- NinjaAPI(..., version='2.0.0')
- NinjaAPI(..., urls_namespace='otherapi')
Already registered: ['api-2.0']
Setup:
core/api.py
from ninja import NinjaAPI
from locations.api import router as locations_router
api = NinjaAPI(
title="Locations API",
version="2.0",
)
api.add_router("/locations/", locations_router)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In my Django project, I'm encountering a ConfigError when trying to register routes for a single instance of NinjaAPI. Despite only creating one API instance, the error suggests that multiple NinjaAPIs or TestClients are registered, requiring unique versioning or URL namespaces. This issue arises when including the API's URLs in the core.urls.py file.
Error:
Setup:
core/api.py
locations/api.py
core/urls.py
Expected Behavior:
The application should recognize the single instance of NinjaAPI without throwing a ConfigError about multiple instances.
Actual Behavior:
A ConfigError is raised, suggesting there are multiple NinjaAPI instances or TestClients, despite there being only one defined in the project.
Environment:
Django version= 4.2.7
Django Ninja version= 1.1.0
Beta Was this translation helpful? Give feedback.
All reactions