jacobian/django-pjax — pull request #6 by alexhayes (2012-03-13 14:39:13+00:00)
Title: pjaxtend - alternative usage

I've added some functionality which I found very useful, basically it operates as follows:

from djpjax import pjaxtend

@pjaxtend('someapp/base.html')
def my_view(request):
return TemplateResponse(request, "template.html", {'my': 'context'})

Then, in your ``template.html`` file you can do the following:

{% extends extend %}
...
...

Note that the template will extend ``someapp/base.html`` unless its a pjax request in which case it will extend ``pjax.html``.

If you want to define which template to extend for a pjax request you can do so as follows:

from djpjax import pjaxtend

@pjaxtend('someapp/base.html', 'my-pjax-extension.html')
def my_view(request):
return TemplateResponse(request, "template.html", {'my': 'context'})

Using this approach you don't need to create lots of ``*-pjax.html`` files, just one pjax.html base file that templates can extend.