LoR as “Local or Remote” is a useful tool for manage static files between testing and production.
Install
Install the package on your system:
pip install django-static-lor
Make the following things in your settings.py:
Add lor app at the beginning of your INSTALLED_APPS
Add LOR_USE_LOCAL_URLS for define if you want local or remote URLs (Better is simply LOR_USE_LOCAL_URLS = DEBUG
Add LOR_STATIC_DIR for define where is the app’s static directory
Add LOR_STATIC_DIR in STATICFILES_DIRS if you want to serve it when DEBUG == False
Add you matches in LOR_FILES_URLS
Your settings will look like something like this:
INSTALLED_APPS = (
'lor',
...
)
LOR_USE_LOCAL_URLS = False
LOR_STATIC_DIR = '/my/lor/static/dir/'
STATICFILES_DIRS = (
...
LOR_STATIC_DIR,
)
LOR_FILES_URLS = {
'jquery': ('js/jquery.js',
'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js')
}
Done!
Usage
In templates
{% load lor %}
My jQuery URL: {% lor_url 'jquery' %}
Collect remote files
./manage.py wget
This will download all files in LOR_FILES_URLS and put them in LOR_USE_LOCAL_URLS.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-static-lor-0.1.0.tar.gz.
File metadata
- Download URL: django-static-lor-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a2f4499a94663dfeb7583240aa747c45faeef5683a1f6f56e5827eac734fca8
|
|
| MD5 |
8c1c1724aec331bac9e52a14820c526e
|
|
| BLAKE2b-256 |
6bd22c0b11fdc55d80f5a428fd2cd2cf5a0b2217bd54497f13cbf3153d688498
|