Skip to content

Commit

Permalink
Made string representation of Router
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliypopel committed Sep 20, 2024
1 parent 3400544 commit 0d5fd0a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/django_routify/_abstraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,19 @@ def route(self, url_path: str, name: str = None):
:return: Any
'''
...

@abstractmethod
def __str__(self) -> str:
'''
Router string representation
:return: str
'''
...

@abstractmethod
def __repr__(self) -> str:
'''
Router string representation
:return: str
'''
...
10 changes: 10 additions & 0 deletions src/django_routify/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,13 @@ def register(view: FUNC_VIEW | View) -> FUNC_VIEW | View:

return view
return register

def __str__(self) -> str:
return f'Router(\n' \
f'\tapp_name:\t"{self.__app_name}"\n' \
f'\turl_prefix:\t"{self.__prefix}"\n' \
f'\turls:\t\t{self.__urls}\n' \
f')'

def __repr__(self) -> str:
return str(self)

0 comments on commit 0d5fd0a

Please sign in to comment.