Pjax(https://github.com/defunkt/jquery-pjax) is a jQuery plugin a standalone JavaScript module that uses ajax (XmlHttpRequest) and pushState() to deliver a fast browsing experience.
Typically django serves each page with a entire page reload, costing performance. Using Pjax, its we convert our django application into a light weight server rendered SPA :) , Lets know how awesome is that..
Here is how to use it and code is hosted at https://github.com/rrmerugu/django-pjaxified.
Step1: Fork and Clone the repo
git clone https://github.com/rrmerugu/django-pjaxifiedStep2: Create virtualenv
virtualenv venvStep3: Activate the
venvand install the necessary packages usingsource venv/bin/activate && pip install -r requirements.txtStep4: start the server :D, all the configs are already added into the
settings. Just start the server withpython manage.py runserverCheck the
djangoajax/settings.pyfor thepjaxsettings. there are only 3 settings needed . Check https://github.com/nigma/django-easy-pjax for settings and implementation doc.website/templates/base.htmlcontains thejslibraries and code needed to activate the pjax on page :) .In the
url/route of django viewwhile extending thebase.htmlinstead of{ % extend s "base.html" % }use{ % extend s "base.html"|pjax:request % }and place the{ % block content % }ofbase.htmlin a div container with id specified inbase.htmlwhich ispjax-containerin our case.
Try it out, and let me know :)
Last modified on 2017-02-25
