Skip to main content

A Django app that provides helpers for serving static files.

Project description

This is a Django app that provides helpers for serving static files.

Django developers mostly concern themselves with the dynamic parts of web applications – the views and templates that render new for each request. But web applications have other parts: the static media files (images, CSS, Javascript, etc.) that are needed to render a complete web page.

For small projects, this isn’t a big deal, because you can just keep the media somewhere your web server can find it. However, in bigger projects – especially those comprised of multiple apps – dealing with the multiple sets of static files provided by each application starts to get tricky.

That’s what staticfiles is for:

Collecting static files from each of your Django apps (and any other place you specify) into a single location that can easily be served in production.

The main website for django-staticfiles is github.com/jezdez/django-staticfiles where you can also file tickets.

Installation

  • Use your favorite Python packaging tool to install staticfiles from PyPI, e.g.:

    pip install django-staticfiles

    You can also install the in-development version of django-staticfiles with pip install django-staticfiles==dev.

  • Added "staticfiles" to your INSTALLED_APPS setting:

    INSTALLED_APPS = [
        # ...
        "staticfiles",
    ]
  • Set your STATIC_URL setting to the URL that handles serving static files:

    STATIC_URL = "/static/"
  • In development mode (when DEBUG = True) the runserver command will automatically serve static files:

    python manage.py runserver
  • Once you are ready to deploy all static files of your site in a central directory (STATIC_ROOT) to be served by a real webserver (e.g. Apache, Cherokee, Lighttpd, Nginx etc.), use the collectstatic management command:

    python manage.py collectstatic

    See the webserver’s documentation for descriptions how to setup serving the deployment directory (STATIC_ROOT).

  • (optional) In case you use Django’s admin app, make sure the ADMIN_MEDIA_PREFIX setting is set correctly to a subpath of STATIC_URL:

    ADMIN_MEDIA_PREFIX = STATIC_URL + "admin/"

Project details


Download files

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

Source Distribution

django-staticfiles-1.1.1.tar.gz (31.5 kB view details)

Uploaded Source

File details

Details for the file django-staticfiles-1.1.1.tar.gz.

File metadata

File hashes

Hashes for django-staticfiles-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a4eec5a28a0ce3c98fdceb40d0d6d6df9ad89a50f75d4735d33f79479e229f43
MD5 19b467020cb4636945140d5211988a71
BLAKE2b-256 c9f22481865768897af6c6f17754695b373350bd5606877f1e95fa2f60e600f4

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page