Skip to content

Commit

Permalink
add docs for route decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Khovanskiy committed Apr 3, 2024
1 parent ec48014 commit ed41a65
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/usage_aiohttp_admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,29 @@ have to inherit from `BaseWidget`. Custom filter have to inherit from
`FilerBase`.


Custom Routes
...............

You can use `@route` decorator to add custom endpoint to your view

.. code-block:: python
from aiohttp_admin2.view import ControllerView
from aiohttp_admin2.views.aiohttp.views.utils import route
class UserView(ControllerView):
controller = UserController
@route(r'/{pk:\d+}/ban/', method='POST')
def ban_user(self, req):
# ban_user(req.match_info['pk'])
return await self.get_detail(req)
`@route` takes 2 parameters: url and method. Valid methods are: `POST`, `GET`, `PUT`, `DELETE`, `HEAD`.
The URL must always start and end with `/`.


Templates
---------

Expand Down

0 comments on commit ed41a65

Please sign in to comment.