Skip to content

fix: double namespace #8923

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion rest_framework/versioning.py

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, you can do in one line

return f"{request.version}:{viewname}" if ":" not in viewname else viewname

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from list comprehension, I'm usually not found of one liners in python.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, can you give me an example of what you want me to add ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ def reverse(self, viewname, args=None, kwargs=None, request=None, format=None, *
)

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):
Expand Down