Skip to main content

Easy PJAX for Django.

Project description

Enhance the browsing experience of Django sites.

Latest Version Downloads License Build Status

Developed at en.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 demo that illustrates this concept in practice and take a look at docs of jquery-pjax to get more information.

The django-easy-pjax app is a helper that makes it trivial to integrate jquery-pjax with your Django 1.5+ site.

Quick Start

Include django-easy-pjax in your requirements file, add easy_pjax to your INSTALLED APPS and make sure that you have the django.core.context_processors.request added to TEMPLATE_CONTEXT_PROCESSORS.

Then simply add |pjax:request filter inside your site template extends tag:

{% extends "theme_base.html"|pjax:request %}

The pjax filter will decide which layout template should be extended based on HTTP headers. In the example above it will return theme_base.html for regular requests and pjax_base.html for PJAX requests.

A generic pjax_base.html template 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 of base and pjax templates as the first parameter:

{% extends "base.html,pjax_base2.html"|pjax:request %}

This is useful if you need to specify another template set.

Unpjax

jquery-pjax uses cache-busting techniques and appends _pjax=true to query string params.

If for some reason you need to remove that param from query strings you can use either the easy_pjax.middleware.UnpjaxMiddleware to remove it from all requests before they are passed to Django views, or the unpjax filter to modify urls emitted in templates:

<a href="{{ request.get_full_path|unpjax }}">

Documentation

The full documentation is at django-easy-pjax.rtfd.org.

A live demo is at easy-pjax.herokuapp.com. You can run it locally after installing dependencies by running python demo.py script from the cloned repository.

License

django-easy-pjax is released under the BSD license.

Other Resources

Please note that the jquery-pjax JavaScript library in not bundled with this app and you still need to add proper handling to your browser-side code.

Commercial Support

This 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 at en@ig.ma.

History

1.1.0 (2014-01-30)

  • Refresh code and compatibility

  • Wheel distribution

  • Add demo at http://easy-pjax.herokuapp.com/

  • Drop official support for Django 1.4 (it should still work though)

1.0.0 (2012-05-29)

  • First release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-easy-pjax-1.1.0.zip (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_easy_pjax-1.1.0-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-easy-pjax-1.1.0.zip.

File metadata

  • Download URL: django-easy-pjax-1.1.0.zip
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-easy-pjax-1.1.0.zip
Algorithm Hash digest
SHA256 637982a05d52c9e0f64a77b45942ba63c41c42966a15c6c54a70d6820380a919
MD5 966456b2ba36406cf89d112fe844d576
BLAKE2b-256 d3472220a2a4a4a6d0ded079dd647acb6ed432f0e129c913cac4abd591659247

See more details on using hashes here.

File details

Details for the file django_easy_pjax-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_easy_pjax-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1e0a6eabf8c934b0efc007b53622e3ec8bd4b9c5bbb96e362b93cbfee0c27a91
MD5 ae369eca32e57dd9cbaf01fc4fc3245d
BLAKE2b-256 70f16a61794a1354f7c513a6b2cd9a829c0296b0480483d8b83c9ceb65197c7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page