0% found this document useful (0 votes)
19 views2 pages

Reduce Memory Load

The document provides instructions for using CompressedManifestStaticFilesStorage in a Django project which involves installing required packages, configuring static file settings, collecting static files, and deploying the Django application.

Uploaded by

Raval Pragnesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Reduce Memory Load

The document provides instructions for using CompressedManifestStaticFilesStorage in a Django project which involves installing required packages, configuring static file settings, collecting static files, and deploying the Django application.

Uploaded by

Raval Pragnesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

To use `CompressedManifestStaticFilesStorage` in your Django project,

follow these steps:

1. **Install Required Packages**:


Make sure you have `django.contrib.staticfiles` included in your
`INSTALLED_APPS` in your Django settings file (`settings.py`). This package
provides the necessary functionality for managing static files.

2. **Configure Static Files Settings**:


In your Django settings file (`settings.py`), configure the static files
settings, including the storage backend to use. Specify
`CompressedManifestStaticFilesStorage` as the storage backend for managing
compressed and versioned static files.

```python
# settings.py

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

STATICFILES_STORAGE =
'django.contrib.staticfiles.storage.CompressedManifestStaticFilesStorag
e'
```

Adjust `STATIC_URL` to match the URL path where your static files will
be served, and `STATIC_ROOT` to specify the directory where collected static
files will be stored.

3. **Collect Static Files**:


Before deploying your Django application, you need to collect static
files into the directory specified by `STATIC_ROOT`. Run the following
command:

```bash
python manage.py collectstatic
```

This command will gather all static files from your Django apps and store
them in the `STATIC_ROOT` directory.
`CompressedManifestStaticFilesStorage` will compress and version these
files during the collection process.

4. **Deploy Your Django Application**:


Deploy your Django application as usual. When Django serves static files
in production, it will use `CompressedManifestStaticFilesStorage` to serve
compressed and versioned files, reducing memory load and improving
performance.

By using `CompressedManifestStaticFilesStorage`, Django will


automatically compress static files (e.g., CSS, JavaScript) during the
collection process and serve them with appropriate caching headers. This
helps reduce the amount of data transferred over the network and improves
the loading time of your web pages.

You might also like