drf-forms/drf-schema-adapter

TypeError: register() got an unexpected keyword argument 'base_name'

Closed this issue · 4 comments

zvyn commented

Currently running ./test.sh fails with the following error:

TypeError: register() got an unexpected keyword argument 'base_name'

The reason is this change in the Django REST Framework released in version 3.9.0: "Deprecate the Router.register base_name argument in favor of basename" -- Release Notes

I'd propose the following fix for now:

  • allow both, base_name and basename for drf-schema-adapter routers
  • translate base_name to basename when passing kwargs to DRF
  • throw a ValueError when both base_name and basename are given

If that sounds good to you I can try to come up with a patch!

I am having the same error trying to follow this cookbook with Python 3.7, Django 3.0 and DRF 3.11. I dont understand why the compatibility matrix says that DRF 3.10 is ok when this change is in DRF 3.9.

As far as I can tell, this change appeared in the documentation of DRF 3.9 but was effective only starting 3.10

Anyway, this has been fixed in release 2.0.7 (a6c7bc0)

Thanks both of you for the feedback

From the release notes of Django RestFramework and DRF 3.9 announcement they mentioned that

Deprecate the Router.register base_name argument in favor of basename. #5990

Which means, the argument base_name is no longer available from DRF=3.11 onwards and use basename instead

So, Change your router config as,

router.register(r'musician', MusicianViewset, basename='musician')
router.register(r'album', AlbumViewset, basename='album')

Thank you, it works now.

Note:just change the base_name -> basename