Skip to content

Commit

Permalink
Added methods params for views registration in example app
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliypopel committed Oct 6, 2024
1 parent a126db4 commit 3dbbdba
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/example/example_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
router = Router('example/', 'example_app')


@router.route('')
@router.route('', methods=['GET'])
def index(request: HttpRequest) -> HttpResponse:
return HttpResponse('''
<h2><ins>Index</ins> page</h2>
<p>This is <b>index</b> view</p>
''')


@router.route('async/', name='async')
@router.route('async/', name='async', methods=['Get'])
async def async_view(request: HttpRequest) -> JsonResponse:
return JsonResponse(
{
Expand All @@ -29,7 +29,7 @@ async def async_view(request: HttpRequest) -> JsonResponse:
)


@router.route('template/')
@router.route('template/', methods=['get'])
class GenericTemplateView(TemplateView):
template_name = 'template.html'

Expand All @@ -39,13 +39,13 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
return context


@router.route('redirect/')
@router.route('redirect/', methods=['GET'])
class GenericRedirectView(RedirectView):
def get_redirect_url(self, *args, **kwargs) -> str:
return reverse('example_app:generic_form')


@router.route('form/')
@router.route('form/', methods=['get', 'post'])
class GenericFormView(FormView):
form_class = Form
template_name = 'form.html'
Expand All @@ -57,7 +57,7 @@ def form_valid(self, form: Form):
))


@router.route('<slug:name>/')
@router.route('<slug:name>/', methods=['GET'])
class HelloView(View):
async def get(self, request: HttpRequest, name: str) -> HttpResponse:
return HttpResponse(f'''
Expand Down

0 comments on commit 3dbbdba

Please sign in to comment.