Skip to main content

OpenSSF Scorecard

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.

#the absolute path where to store the .zip and the html files
#default value is a folder named 'freeze' located as sibling of 'settings.MEDIA_ROOT'
FREEZE_ROOT = '/...'

#tells 'freeze' if the urls should be fetched using https instead of http protocol (only if FREEZE_SITE_URL is not defined)
FREEZE_USE_HTTPS = False

#the site-url to crawl, if not specified it will be autodetected using the sites app
FREEZE_SITE_URL = 'http://mydomain.com'

#the base-url for all links relative to root '/'
#useful if the generated static site will run in a specific folder which is not the document-root
FREEZE_BASE_URL = None

#if True 'freeze' will convert all absolute urls to relative urls
#useful if the generated static site will run locally (file://) or in an unknown folder which is not the document-root (only if FREEZE_BASE_URL is not defined)
FREEZE_RELATIVE_URLS = False

#if True 'freeze' will inject a script at the end of each page
#which will force hrefs like 'path/' to 'path/index.html' (only if the site is running under file://)
#useful if the generated static site will run locally (requires FREEZE_RELATIVE_URLS set to True) to prevent local directory index
FREEZE_LOCAL_URLS = False

#if True 'freeze' will fetch each url founded in sitemap.xml
FREEZE_FOLLOW_SITEMAP_URLS = True

#if True 'freeze' will follow and fetch recursively each link-url founded in each page
FREEZE_FOLLOW_HTML_URLS = True

#if true 'freeze' will send an email to managers containing the list of all invalid urls (404, 500, etc..)
FREEZE_REPORT_INVALID_URLS = False

#the invalid urls email report subject
FREEZE_REPORT_INVALID_URLS_SUBJECT = '[freeze] invalid urls'

#if True the generated site will contain also the MEDIA folder and ALL its content
FREEZE_INCLUDE_MEDIA = True
#elif the value is a list or tuple only the specified directories will be included
FREEZE_INCLUDE_MEDIA = ('cache', 'images', 'videos', )

#if True the generated site will contain also the STATIC folder and ALL its content
FREEZE_INCLUDE_STATIC = True
#elif the value is a list or tuple only the specified directories will be included
FREEZE_INCLUDE_STATIC = ('myapp1', 'myapp2', 'myapp3', )

#if True the generated site will be zipped, the *.zip file will be created in FREEZE_ROOT
FREEZE_ZIP_ALL = False

#the name of the zip file created
FREEZE_ZIP_NAME = 'freeze'

#The request headers to use during the get requests that scrape the site
#can be used to set Authentication headers, by default sets the user-agent
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

# clone repository
git clone https://github.com/fabiocaccamo/django-extra-settings.git && cd django-extra-settings

# create virtualenv and activate it
python -m venv venv && . venv/bin/activate

# upgrade pip
python -m pip install --upgrade pip

# install requirements
pip install -r requirements.txt -r requirements-test.txt

# install pre-commit to run formatters and linters
pre-commit install --install-hooks

# run tests
tox
# or
python runtests.py
# or
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 Bluesky
  • :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-email-validators - no more invalid or disposable emails in your database. ✉️ ✅

  • 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. 🧟‍♂️

Download files

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

Source Distribution

django_freeze-0.13.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_freeze-0.13.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file django_freeze-0.13.0.tar.gz.

File metadata

  • Download URL: django_freeze-0.13.0.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for django_freeze-0.13.0.tar.gz
Algorithm Hash digest
SHA256 bd7eedf8ac57ac84a09e64bba18e6a0f4be5aa7e5ca3f57eb200c0f96b899467
MD5 b393420e1c33c17d2841ced52667f32b
BLAKE2b-256 2aeb6eead6515cabea62a8c28cd670451abce213c151d410ebb028867fb20952

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_freeze-0.13.0.tar.gz:

Publisher: create-release.yml on fabiocaccamo/django-freeze

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_freeze-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: django_freeze-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for django_freeze-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58143fca47dcc1aa6aeddc79857e6604a54fa3ea4fcfd7509caaeb3b6252f024
MD5 1de6372e1c81c996724f64496d239fc7
BLAKE2b-256 2c2790bf719eca2a066656dabd8daf92b1e6b376520c24593d2ef55f995e34e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_freeze-0.13.0-py3-none-any.whl:

Publisher: create-release.yml on fabiocaccamo/django-freeze

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.13.0 This release

2 files

0.12.0

2 files

0.11.1

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.4

1 file

0.6.3

1 file

0.6.2

1 file

0.6.1

1 file

0.6.0

0.5.3

1 file

0.5.2

1 file

0.5.1

1 file

0.5.0

1 file

0.4.3

1 file

0.4.2

1 file

0.4.1

1 file

0.4.0

1 file

0.3.0

1 file

0.2.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page