Package: django-easy-pjax
Enhance the browsing experience of Django sites.Developed aten.ig.ma software shop.What is PJAX?PJAX utilizes pushState and Ajax to load HTML from the server into the current
page without a full reload. It’s Ajax with real permalinks, page titles,
and a working back button that fully degrades.Check out the demothat illustrates this concept
in practice and take a look at docs ofjquery-pjaxto get more information.Thedjango-easy-pjaxapp is a helper that makes it easy to integratejquery-pjaxwith your Django 1.5+ site.Quick StartFirst includedjango-easy-pjax==1.3in yourrequirements.txtfile,
addeasy_pjaxto yourINSTALLED APPSand make sure you havedjango.template.context_processors.requestadded to templatecontext_processors.If you are using Django 1.9+, you will also need to add theeasy_pjax.templatetags.pjax_tagsto templatebuiltinsin your
Django settings:TEMPLATES=[{"BACKEND":"django.template.backends.django.DjangoTemplates","DIRS":[...],"APP_DIRS":True,"OPTIONS":{"builtins":["easy_pjax.templatetags.pjax_tags"],"context_processors":["django.template.context_processors.request","django.template.context_processors.static",...]}}]Then simply add|pjax:requestfilter inside your site templateextendstag:{% extends "theme_base.html"|pjax:request %}Thepjaxfilter will decide which layout template should be extended based
on HTTP headers. In the example above it will returntheme_base.htmlfor regular requests andpjax_base.htmlfor PJAX requests.A genericpjax_base.htmltemplate is provided by this application, but you
may need to copy it to your templates root directory and adjust it to match
your project’s template blocks.No other modification to views, code or url configuration is required,
so integration with other applications shouldn’t be a problem.The template filter also takes a comma-separated names ofbaseandpjaxtemplates as the first parameter:{% extends "base.html,pjax_base2.html"|pjax:request %}This is useful if you need to specify another template set.See thedemo.pyfile andtestsdirectory for working examples.Unpjaxjquery-pjaxuses cache-busting techniques and appends_pjax=trueto query string params.If for some reason you need to remove that param from query strings
you can use either theeasy_pjax.middleware.UnpjaxMiddlewareto remove it
from all requests before they are passed to Django views, or theunpjaxfilter to modify urls emitted in templates:<a href="{{ request.get_full_path|unpjax }}">DocumentationThe full documentation is atdjango-easy-pjax.rtfd.org.A live demo is ateasy-pjax.herokuapp.com.
You can run it locally after installing dependencies by runningpython demo.pyscript from the cloned repository.Django 1.9Before Django 1.9 theeasy-pjaxlibrary used thedjango.template.base.add_to_builtinsprivate API to automatically register itself in the template built-ins after it was added
to theINSTALLED_APPSlist.
This workaround was due to the fact that the{% load  %}tag cannot be placed before
the{% extends %}tag and thepjaxtemplate filter could not be loaded explicitly.Starting from Django 1.9easy-pjaxdoes not have to rely on such workarounds because
Django now provides a clean way to add filters and tags to templatebuilt-ins.
This is now the recommended and the only way of installingeasy-pjaxtemplate tags, also because theadd_to_builtins API was removed.This is a backward incompatible change, but one that makes the integration more explicit and
following the Zen of Python.Example of configuration settings to be used starting from Django 1.9:INSTALLED_APPS=["easy_pjax"]MIDDLEWARE_CLASSES=["easy_pjax.middleware.UnpjaxMiddleware"]TEMPLATES=[{"BACKEND":"django.template.backends.django.DjangoTemplates","DIRS":[],"APP_DIRS":True,"OPTIONS":{"builtins":["easy_pjax.templatetags.pjax_tags"],"context_processors":["django.template.context_processors.request",]}}]No changes are required for Django 1.8 or older.Licensedjango-easy-pjaxis released under the BSD license.Other ResourcesGitHub repository -https://github.com/nigma/django-easy-pjaxPyPi Package site -http://pypi.python.org/pypi/django-easy-pjaxPlease note that thejquery-pjaxJavaScript library in not bundled with this
app and you still need to add proper handling to your browser-side code.Commercial SupportThis app and many other help us build better software
and focus on delivering quality projects faster.
We would love to help you with your next project so get in touch
by dropping an email aten@ig.ma.History1.3.0 (2016-02-21)Django 1.9 support (the plugin should be added toTEMPLATES["OPTIONS"]["builtins"]settings) -#13Fix handling of non-ascii query strings on Python 2.7 -#141.2.0 (2015-04-23)Django 1.7/1.8 compatibility (thanks to @scottwoodall)1.1.0 (2014-01-30)Refresh code and compatibilityWheel distributionAdd demo athttp://easy-pjax.herokuapp.com/Drop official support for Django 1.4 (it should still work though)1.0.0 (2012-05-29)First release