Skip to main content

Django app that caches CDN files for use when coding offline

Project description

This app is to help in those situations where you can’t get on the network but you want to write some Django code. Surround your static CDN references (like jquery and the like) with this template tag and when you turn it on the URLs will be re-written from a local copy.


In your settings file, add ‘airplane’ to your settings.INSTALLED_APPS field and make the following additions:

import airplane

    os.path.join(BASE_DIR, airplane.CACHE_DIR),


Now use the airplane tag in your templates

{% load airplanetags %}

        <link rel="stylesheet"
            href="{% airplane '' %}">

Change the AIRPLANE_MODE setting to airplane.USE_CACHE and subsequent calls to the {% airplane %} tag will return a reference to the locally cached version.


Airplane only does something if DEBUG=True and if you have an AIRPLANE_MODE value set to either airplane.BUILD_CACHE or airplane.USE_CACHE. If one of these conditions is not met, the tag simply returns the value passed in.

For example, if DEBUG=False and your template contains:

<link rel="stylesheet"
    href="{% airplane '' %}">

Then the above snippet renders as:

<link rel="stylesheet"

When AIRPLANE_MODE is set to airplane.BUILD_CACHE any URLs passed in are fetched and their contents added to a local cache. The default local cache is .airport_cache relative to the base directory of your project.

You can change the location of the cache by setting AIRPLANE_CACHE. The setting accepts either fully qualified paths or paths relative to the project’s base directory.

Once you have cached all the files you are using, switch AIRPLANE_MODE to airplane.USE_CACHE. All URLs are now re-written to point to the contents of the local cache.


django-airplane has been tested with:

  • Python 2.7, 3.6, 3.7 and Django 1.11
  • Python 3.6, 3.7 and Django 2.1
  • Python 3.6, 3.7 and Django 2.2

Project details

Download files

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

Files for django-airplane, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size django_airplane-0.3.1-py2.py3-none-any.whl (8.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size django-airplane-0.3.1.tar.gz (6.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page