django-freeze
django-freeze generates the static version of your django site.
Just run python manage.py generate_static_site
:)
Features
- Generate the static version of your Django site, optionally compressed .zip file
- Generate/download the static site using urls (only superuser and staff)
- Follow sitemap.xml urls
- Follow internal links founded in each page
- Follow redirects
- Report invalid/broken urls
- Selectively include/exclude media and static files
- Custom base url (very useful if the static site will run in a specific folder different by the document-root)
- Convert urls to relative urls (very useful if the static site will run offline or in an unknown folder different by the document-root)
- Prevent local directory index
Installation
- Run
pip install django-freeze
- Add
freeze
to settings.INSTALLED_APPS
- Enable the
sites
framework (instructions here) - Restart your application server
Configuration (optional)
All these settings are optional, if not defined in settings.py
the default values (listed below) will be used.
FREEZE_ROOT = '/...'
FREEZE_USE_HTTPS = False
FREEZE_SITE_URL = 'http://mydomain.com'
FREEZE_BASE_URL = None
FREEZE_RELATIVE_URLS = False
FREEZE_LOCAL_URLS = False
FREEZE_FOLLOW_SITEMAP_URLS = True
FREEZE_FOLLOW_HTML_URLS = True
FREEZE_REPORT_INVALID_URLS = False
FREEZE_REPORT_INVALID_URLS_SUBJECT = '[freeze] invalid urls'
FREEZE_INCLUDE_MEDIA = True
FREEZE_INCLUDE_MEDIA = ('cache', 'images', 'videos', )
FREEZE_INCLUDE_STATIC = True
FREEZE_INCLUDE_STATIC = ('myapp1', 'myapp2', 'myapp3', )
FREEZE_ZIP_ALL = False
FREEZE_ZIP_NAME = 'freeze'
FREEZE_REQUEST_HEADERS = {'user-agent': 'django-freeze'}
Add freeze.urls to urls.py
if you want superusers and staff able to use freeze urls.
urlpatterns = patterns('',
...
url(r'^freeze/', include('freeze.urls')),
...
)
Usage
Terminal
Run python manage.py generate_static_site
URLs
Superusers and staff can use the following urls to download a .zip containing the generated static site or to just generate the static website.
/freeze/download-static-site/
/freeze/generate-static-site/
(the time necessary to generate the static site depends on the size of the project)
TODO
- Write tests
- Add
sitemap.xml
and robots.txt
to the generated static site
Testing
git clone https://github.com/fabiocaccamo/django-extra-settings.git && cd django-extra-settings
python -m venv venv && . venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-test.txt
pre-commit install --install-hooks
tox
python runtests.py
python -m django test --settings "tests.settings"
License
Released under MIT License.
Supporting
- :star: Star this project on GitHub
- :octocat: Follow me on GitHub
- :blue_heart: Follow me on Twitter
- :moneybag: Sponsor me on Github
See also
-
django-admin-interface
- the default admin interface made customizable by the admin itself. popup windows replaced by modals. 🧙 ⚡
-
django-cache-cleaner
- clear the entire cache or individual caches easily using the admin panel or management command. 🧹✨
-
django-colorfield
- simple color field for models with a nice color-picker in the admin. 🎨
-
django-extra-settings
- config and manage typed extra settings using just the django admin. ⚙️
-
django-maintenance-mode
- shows a 503 error page when maintenance-mode is on. 🚧 🛠️
-
django-redirects
- redirects with full control. ↪️
-
django-treenode
- probably the best abstract model / admin for your tree based stuff. 🌳
-
python-benedict
- dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘
-
python-codicefiscale
- encode/decode Italian fiscal codes - codifica/decodifica del Codice Fiscale. 🇮🇹 💳
-
python-fontbro
- friendly font operations. 🧢
-
python-fsutil
- file-system utilities for lazy devs. 🧟♂️