Skip to content

valberg/django-view-decorator

Repository files navigation

Django View Decorator

Tests Documentation pre-commit.ci status PyPI - Version PyPI - Python Version


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

Installation

pip install django-view-decorator

Usage

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:

Function-based views

# foos/views.py
from django_view_decorator import view

@view(paths="/foo/", name="foo")
def foo(request: HttpRequest) -> HttpResponse:
    return HttpResponse("foo")

Class-based views

@view(paths="/foo/", name="foo-list")
class FooList(ListView):
    model = Foo

Development

git clone
cd django-view-decorator
pip install hatch
hatch run tests:cov
hatch run tests:typecheck

License

django-view-decorator is distributed under the terms of the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages