Skip to content
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
Collaborator

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