django-view-decorator is decorator aimed at bringing locality of behaviour to the connection between a URL and a view in Django.
Read more about the motivation behind the package in a recent blogpost.
Table of Contents
pip install django-view-decorator
Setup the project URLconf to include URLs from django-view-decorator:
# project/urls.py (this is what we point the ROOT_URLCONF setting at)
from django.urls import path
from django_view_decorator import include_view_urls
urlpatterns = [
path("", include_view_urls()),
]
Use the decorator like so, for:
# foos/views.py
from django_view_decorator import view
@view(paths="/foo/", name="foo")
def foo(request: HttpRequest) -> HttpResponse:
return HttpResponse("foo")
@view(paths="/foo/", name="foo-list")
class FooList(ListView):
model = Foo
git clone
cd django-view-decorator
pip install hatch
hatch run tests:cov
hatch run tests:typecheck
django-view-decorator
is distributed under the terms of the MIT license.