From 1381307c074e957ee78d7f9b9ec8f702fba21c52 Mon Sep 17 00:00:00 2001 From: Altimore Date: Thu, 30 Mar 2023 13:32:37 +0400 Subject: [PATCH] fix: double namespace When using namespaces on my apps and django generic relation project 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 ``` so i just added a test in def get_versioned_viewname(self, viewname, request): to not change the view name i there is already a namespace. --- rest_framework/versioning.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rest_framework/versioning.py b/rest_framework/versioning.py index 78cfc9dc8..751df5be5 100644 --- a/rest_framework/versioning.py +++ b/rest_framework/versioning.py @@ -135,8 +135,10 @@ class NamespaceVersioning(BaseVersioning): ) def get_versioned_viewname(self, viewname, request): - return request.version + ':' + viewname - + if not ":" in viewname: + return request.version + ":" + viewname + else: + return viewname class HostNameVersioning(BaseVersioning): """