drf-nested-routers
drf-nested-routers copied to clipboard
Add suport to django > 3.0 and drf > 3.9
I was using the base_name argument on the urls of my app but i believe drf isn't supporting it anymore because when testing the following error is returned.
Traceback (most recent call last):
File "manage.py", line 29, in <module>
main()
File "manage.py", line 25, in main
execute_from_command_line(sys.argv)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/management/base.py", line 366, in execute
self.check()
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/management/base.py", line 395, in check
include_deployment_checks=include_deployment_checks,
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/management/base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/circleci/company_service/.venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "/home/circleci/company_service/.venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/circleci/company_service/company_service/urls.py", line 16, in <module>
companies_router.register('production_lines', views.ProductionLineViewSet, base_name='companies-production_lines')
TypeError: register() got an unexpected keyword argument 'base_name'
Exited with code exit status 1
Yes, I saw this. Am having the same problem right now.
DRF 3.11 changed from base_name
to basename
, and this propagates automatically.
I (or somebody else) will need to fix this. There is a PR already with fixed code bug old tests needing update. You can use the branch or revert to a pre-3.11 version of DRF until this got fixed here.
Thanks for the report.
I tested the branch of @Frankkkkk and it works
requirements.txt
# drf-nested-routers==0.91
-e git+https://github.com/Frankkkkk/drf-nested-routers.git@a3bb6be19d8444431df7e9c0785d56f36c99c8ab#egg=drf-nested-routers
-- tag https://github.com/alanjds/drf-nested-routers/pull/151
Yes, the branch works. The PR only changes tests. Right now drf-nested-routers works with latest DRF release, but tests are not passing on it.
The PR you linked passes on latest DRF but fails on old ones. However the module will work on both for now.
I see that you merged #186 which should add support for Django 3 but didn't create a new version for pypi.
Version 0.92.1 was released to PyPI yesterday. Thanks for the heads up.
I've tried version 0.92.1 and I'm still seeing the TypeError: register() got an unexpected keyword argument 'base_name'
, I'm on DRF 3.12.1. No error when i change base_name
to basename
. It's probably worth updating the README to reduce the number of folks stumbling on the same issue.
Lately I am thinking in just deprecate DRF 3.11 in December. Holidays will (hopefully) let me take care of this.
You are right. This is cumbersome and letting people confused.
Was this perhaps resolved in the 0.93 version(s)?
Wondering if there is any progress in this? I noticed https://github.com/alanjds/drf-nested-routers/pull/317 and wondered the PR would get reviewed at some point. Thanks!
I just merged #317. Thanks @nattiechan for the nudge.
Will close this issue now.