Django PDF rendering, session activity and other app releases

Easy Django PDF rendering

django-easy-pdf makes PDF from HTML templates rendering really simple. It can be used to dynamically generate invoices, bills, tickets and other documents.

It works in the same way as Django TemplateView, but outputs PDF instead of HTML. Just start by creating a Django template file:

{% extends "easy_pdf/base.html" %}

{% block content %}
    <div id="content">
        <h1>Hi there!</h1>
{% endblock %}

And then add a simple view that will do all the lifting and return PDF content:

from easy_pdf.views import PDFTemplateView

class HelloPDFView(PDFTemplateView):
    template_name = "hello.html"

Check out the demo at, docs and github repo.

Signing out from all active sessions

django-session-activity is an app that allows authenticated users to inspect their session activity and sign out from all open sessions, even the ones opened on remote computers, with a single click.

List of active sessions

This is a feature that can be found in other web apps like Gmail or Github and is aimed at improving user security. It integrates with any auth framework that builds upon django.contrib.auth and has no extra dependencies.

There's an instant demo that can be run from the cloned github repo by typing python

X-Request-Id logging

Making sense from log data aggregated from dozens of servers may be a challenging task.

There are services like Papertrail or Loggly that do the heavy work of collecting and indexing logs in real-time, but without a unique request IDs it may impossible to match interleaved server and application logs with a particular HTTP request.

Using django-request-id we can easily add a Request ID to each log line and then grep or search by that value to track that single request and make sense from the logs:

app[web.17]: DEBUG request_id=88888888-8888-4888-8888-888888888888 event="Auth header received"
app[web.21]: INFO  request_id=11111111-1111-4111-1111-111111111111 event="Sending update"
app[web.17]: DEBUG request_id=88888888-8888-4888-8888-888888888888 event="Auth: existing client found"
heroku[router]: at=info method=GET path=/v1.0/client/ping request_id=88888888-8888-4888-8888-888888888888

Check out the docs at and github repo.

Easy PJAX in Django

The django-easy-pjax now has a demo site at

We use PJAX (pushState and Ajax) to improve user experience and load only the important HTML content from the server into the current page without a full reload. It makes sites more responsive because static assets (css and js) are retrieved and parsed only on the initial request.

Integration easy-pjax with Django projects is really simple and involves just a couple steps:

  1. Adding easy_pjax to INSTALLED APPS

  2. Making site_base.html template to dynamically extend from theme_base.html or pjax_base.html:

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

There is no need to modify views or urls code so it can work with 3rd party apps as well.

Read more at and check the demo in the github repo.

Other releases

Make sure to check out other handy packages at and follow us for future updates:

dj-cmd - forget python and invoke any Django command by simply typing dj r (runserver), dj m (migrate) or dj cs (python collectstatic --noinput) from any project directory. Define your own shortcuts and save typing.

django-twilio-sms integrate with Twilio like a boss. Send and receive SMS messages in your Django app, track delivery and persist messages to database.

heroku-django-cookbook - collection of snippets and scripts that solve certain problems when deploying Django apps to Heroku.

django-infinite-pagination - efficiently paginates large object collections on systems where using standard Django Paginator is impractical because of significant count(*) query overhead (i.e. PostgreSQL).

djutil - a collection of useful base model, view mixins, storage backends, unique upload path generators and other helpers.

Pull requests and feedback are always welcome.

What's in the pipeline?

Django multi-tenant solutions, mobile client integration, push notifications and more. Stay tuned!

Commercial support

Apart from investing in Open Source we do a lot of professional web, API and mobile backend development.

The above apps 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

Article "Django PDF rendering, session activity and other app releases" was published on Feb. 6, 2014 and tagged under django, heroku, pdf-rendering, pjax, python, session-activity and x-request-id. You can it if you like or leave a comment below.

Previous article: Django on Heroku: installing NodeJS and Less for static assets compilation