From 08e200e1e9b7ffab2182f39c181f6d359d137c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Wed, 21 Jun 2023 00:06:46 +0200 Subject: [PATCH] WIP. --- content/django-view-decorator.md | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/content/django-view-decorator.md b/content/django-view-decorator.md index 863a872..f7f3dd7 100644 --- a/content/django-view-decorator.md +++ b/content/django-view-decorator.md @@ -191,25 +191,6 @@ This opens up a quite nifty possibility of injecting URLs into a namespace from Now we can treat `custom_view` as if it was a part of the `app_1` namespace. Ie. `reverse("app_1:custom-view")` would give us `app_1/my-custom-view/`. Neat! -## One decorator to rule them all? - -One feature of `django-view-decorator` which I'm not sure if makes sense, is the idea to embed other decorators into it. For example, instead of: - - :::python - @view(paths="/foo/", name="foo") - @login_required - def foo(request: HttpRequest) -> HttpResponse: - return "bar" - -We can just write: - - :::python - @view(paths="/foo/", name="foo", login_required=True) - def foo(request: HttpRequest) -> HttpResponse: - return "bar" - -At the time of writing `login_required`, `staff_required` and permission checking is included in the decorator. But either the decorator should support, at least, all decorators in `django.views.decorators`, or not at all. - ## The path to Django core So, as I wrote initially, I have a mission to try to get this pattern into Django core. This is not going to be an easy feat.