Skip to main content

A small extension to download css and js vendor files from CDNs and host them locally.

Project description



Install using pip:

pip install django-vendor-files

Add vendor_files to INSTALLED_APPS in your Django settings:


Put the vendor directory in STATICFILES_DIRS in your Django settings:

    os.path.join(BASE_DIR, 'vendor/'),

Add a VENDOR setting to your Django settings, and add your vendor files with URL and SNI, e.g.:

    'jquery': {
        'url': '',
        'js': [
                'path': 'jquery-3.2.1.min.js',
                'sri': 'sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=',
    'bootstrap': {
        'url': '',
        'js': [
                'path': 'js/bootstrap.min.js',
                'sri': 'sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa',
        'css': [
                'path': 'css/bootstrap.min.css',
                'sri': 'sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u',


Put {% load vendor_tags %} at the top of your Django template and the vendor tag , e.g.: {% vendor 'jquery' %}, somewhere in your HTML:

{% load staticfiles %}
{% load vendor_tags %}

<!DOCTYPE html>
        <title>{{ }}</title>
        {% vendor 'jquery' %}
        {% vendor 'bootstrap' %}

Then, you have 2 options:

  1. To use a CDN, put VENDOR_CDN = True in your Django settings and the vendor tag will be replaced by a <link> or <script> tag using the URLs in the settings.

  2. To use a local copy, put VENDOR_CDN = False (or nothing at all) in your Django settings and the vendor tag will be replaced by a <link> or <script> tag using your STATIC_PATH. The files can be downloaded:

    python ./ download_vendor_files

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-vendor-files, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django-vendor-files-0.1.1.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page