aaronbassett / django-GNU-Terry-Pratchett

You know they'll never really die while the Trunk is alive
BSD 3-Clause "New" or "Revised" License
27 stars 6 forks source link

Django GNU Terry Pratchett

Keeping the legacy of Sir Terry Pratchett alive forever. For as long as his name is still passed along the Clacks, Death can't have him.

with thanks to this reddit thread

Installation

You can install from pypi:

pip install django-GNU-Terry-Pratchett

or from source:

git clone git@github.com:aaronbassett/django-GNU-Terry-Pratchett.git
cd django-GNU-Terry-Pratchett
python setup.py install

Once installed add the middleware to you project:

MIDDLEWARE_CLASSES=(
    ...
    'gnu_terry_pratchett.middleware.ClacksMiddleware',
),

We also provide a view decorator and a mixin for your Class-Based Views if you don't want to have the header on every response.

from gnu_terry_pratchett.decorators import clacks_overhead
from gnu_terry_pratchett.views import ClacksMixin

# function view
@clacks_overhead
def my_view(request):
    ...
    return my_response

# CBV
class MyView(ClacksMixin, View):
    def get(self, request):
        ...
        return my_response