Conversation
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.
auvipy
left a comment
There was a problem hiding this comment.
can you please add test case to verify this change?
There was a problem hiding this comment.
Instead, you can do in one line
return f"{request.version}:{viewname}" if ":" not in viewname else viewname
There was a problem hiding this comment.
Apart from list comprehension, I'm usually not found of one liners in python.
There was a problem hiding this comment.
Sure, can you give me an example of what you want me to add ?
There was a problem hiding this comment.
Sure, can you give me an example of what you want me to add ?
i mean where should i add test case and in which way ?
There was a problem hiding this comment.
here you can check for existing tests https://github.com/encode/django-rest-framework/blob/master/tests/test_versioning.py and then add your relevant additional unit tests
There was a problem hiding this comment.
here you can check for existing tests https://github.com/encode/django-rest-framework/blob/master/tests/test_versioning.py and then add your relevant additional unit tests
|
if possible, can you please also check this PR #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. |
auvipy
left a comment
There was a problem hiding this comment.
I would like to see unit test coverage for this change
|
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. |
|
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
and this is what i get in the console
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.