fix: double namespace
Description
When using namespaces on my apps and rest framework generic relation https://github.com/LilyFoote/rest-framework-generic-relations project with the i get a double name space : in relations.py i added this print statement on the line 383 before the matching viewname test
print(
f"Comparing '{match.view_name}' to '{expected_viewname}', self.view_name = {self.view_name} "
)
and this is what i get in the console
Comparing invoices:invoice-detail to reminders:invoices:invoice-detail, self.view_name = invoices:invoice-detail
solution
so i just added a test in def get_versioned_viewname(self, viewname, request): to not change the view name if there is already a namespace.
alternative
we could take out the existing namespace to replace it with the required one or we could make a more precise error message to explain how to bypass this behavior.
My use case required the reminder namespace to not be added.
if possible, can you please also check this PR https://github.com/encode/django-rest-framework/pull/7278
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
https://docs.djangoproject.com/en/5.0/topics/http/urls/#url-namespaces
Namespaces can also be nested. The named URL 'sports:polls:index' would look for ...