Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested Routes will fail with drf >v3.15.0 #346

Open
jokiefer opened this issue Oct 18, 2024 · 1 comment
Open

Nested Routes will fail with drf >v3.15.0 #346

jokiefer opened this issue Oct 18, 2024 · 1 comment

Comments

@jokiefer
Copy link

In v3.15.0 the register function will fail with nested routes, cause the basename will be checked.

def register(self, prefix, viewset, basename=None):
        if basename is None:
            basename = self.get_default_basename(viewset)

        if self.is_already_registered(basename):
            msg = (f'Router with basename "{basename}" is already registered. '
                   f'Please provide a unique basename for viewset "{viewset}"')
            raise ImproperlyConfigured(msg)

This will always raise ImproperlyConfigured exception if there are more then one nested routes based on the same root path.

example:

router.register(r'wms', service_views.WebMapServiceViewSet, basename='wms')
          .register(r'layers', service_views.NestedLayerViewSet, basename='wms-layers', parents_query_lookups=['service']),
    router.register(r'wms', service_views.WebMapServiceViewSet, basename='wms')
          .register(r'service-contact', metadata_views.NestedServiceContactViewSet, basename='wms-service-contact', parents_query_lookups=['service_contact_webmapservice_metadata']),
    

@auvipy
Copy link
Collaborator

auvipy commented Nov 17, 2024

thanks for the report. do you have plans for the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants