I am running a Django application in Docker when I spinup the docker container I get the error
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.9/site-packages/django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 36, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 128, in handle_uncaught_exception
callback, param_dict = resolver.resolve_error_handler(500)
File "/usr/local/lib/python3.9/site-packages/django/urls/resolvers.py", line 597, in resolve_error_handler
callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
File "/usr/local/lib/python3.9/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.9/site-packages/django/urls/resolvers.py", line 577, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/repo/repo/repo/urls.py", line 28, in <module>
api.add_router("/xxxxx/", xxxxx_router)
File "/usr/local/lib/python3.9/site-packages/ninja/main.py", line 367, in add_router
self._routers.extend(router.build_routers(prefix))
File "/usr/local/lib/python3.9/site-packages/ninja/router.py", line 366, in build_routers
raise ConfigError(
ninja.errors.ConfigError: Router@'/xxxxx/' has already been attached to API NinjaAPI:1.0.0
The start script start.sh
using gunicorn
echo Starting Gunicorn.
export PYTHONPATH=repo
exec gunicorn repo.wsgi:application \
--bind :8000 \
--workers 5 \
--threads 2 \
--worker-class gevent \
--timeout 120 \
--limit-request-line 0 \
--limit-request-fields 0 \
--limit-request-field_size 0
Docker
RUN chmod -R 755 repo/start.sh
ENTRYPOINT ["repo/start.sh"]
Docker compose
version: '3'
services:
repo:
build: .
platform: linux/amd64
env_file:
- .env.dev
ports:
- 8000:8000
I have looked checked if multiple instances of Ninja API I have checked if I installed the api instance in multiple areas https://github.com/vitalik/django-ninja/issues/229