Django staticfiles extension to download third-party static files
Project description
django-staticfiles-downloader provides staticfiles_downloader.DownloaderFinder, an extension of django.contrib.staticfiles, which allows you to specify static files with urls and optionaly checksum in your Django application or Django project settings. This is particularly useful, when using third-party static files, if you don’t want to either include the files in your project nor depend on CDN in runtime.
The static files are collected with python manage.py collectstatic.
Installation
pip install django-staticfiles-downloader
Configuration
Add staticfiles_downloader.DownloaderFinder to settings.STATICFILES_FINDERS:
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'staticfiles_downloader.DownloaderFinder',
]
Define static files urls in your Django application
# your_app/__init__.py
staticfiles_urls = {
# use only url
'my_app/js/jquery-3.2.1.min.js': 'https://code.jquery.com/jquery-3.2.1.min.js',
# or use url and checksum
'my_app/js/jquery-2.2.4.min.js': (
'https://code.jquery.com/jquery-2.2.4.min.js',
'sha384',
'rY/jv8mMhqDabXSo+UCggqKtdmBfd3qC2/KvyTDNQ6PcUJXaxK1tMepoQda4g5vB',
),
}
Define static files urls in your Django project settings
# your_project/settings.py
STATICFILES_URLS = {
# use only url
'js/jquery-3.2.1.min.js': 'https://code.jquery.com/jquery-3.2.1.min.js',
# or use url and checksum
'js/jquery-2.2.4.min.js': (
'https://code.jquery.com/jquery-2.2.4.min.js',
'sha384',
'rY/jv8mMhqDabXSo+UCggqKtdmBfd3qC2/KvyTDNQ6PcUJXaxK1tMepoQda4g5vB',
),
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-staticfiles-downloader-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4e004ecee90eff82e8034ac1eeec954d95446c9b99b5b68b4f14f5c09991842 |
|
MD5 | 43c1f88e0324d0401a32a36222a5065e |
|
BLAKE2b-256 | c95f214c7caa51e77182a85432dbae83cabd39fe1849f3f478337dba5dcebd1f |