Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

PJAX Templating for Flask Applications

Project Description


Add a fairly basic handler for PJAX to Flask.

Allows you to specify a base template for both a normal request or a PJAX request. This allows you to return the required code blocks, and choose what you wish to render.


pip install flask-pjax


Configiguring Flask-PJAX is fairly simple. To get started, initalise it against your application.

from flask import Flask
from flask_pjax import PJAX

app = Flask(__name__)


from flask import Flask
from flask_pjax import PJAX

app = Flask(__name__)
pjax = PJAX(app)


from flask import Flask
from flask_pjax import PJAX

pjax = PJAX()

def create_app():
    app = Flask(__name__)
    return app

Currently, the base template for your PJAX request is the only configuration item. This is set to the location of the template within your project.

PJAX_BASE_TEMPLATE = "pjax.html"


You can return your templates like you normally do.


def index():
    return render_template('index.html')

Your base template remains the same.

# base.html

    {% block content %}{% endblock %}

And you create a PJAX base template.

# pjax.html


{% block content %}{% endblock %}

And within your index template, you can specify your base template:

# index.html

{% extends pjax('base.html') %}

<title>Woop - Home</title>

{% block content %}
This is my homepage
{% endblock %}

This will render the pjax.html for PJAX requests, and the base for non-PJAX requests.

Furthermore, you can specify a custom PJAX Base Template:

{% extends pjax('base.html', pjax='/base/custom_pjax_template') %}


  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a Contributor Friendly tag for issues that should be ideal for people who are not very familiar with the codebase yet.
  2. Fork the repository on Github to start making your changes to the master branch (or branch off of it).
  3. Write a test which shows that the bug was fixed or that the feature works as expected.
  4. Send a pull request and bug the maintainer until it gets merged and published.


0.0.1 (29/9/2013)

  • Conception.
  • Initial Commit of Package to GitHub.
  • First Release.
Release History

Release History

This version
History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Flask-PJAX-0.0.1.tar.gz (3.6 kB) Copy SHA256 Checksum SHA256 Source Sep 29, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting