Theme
Version
GitHubPyPIDiscord
On this page

Upgrading from 0.x versions

This page is for projects that still run a 0.x release of django-components. Before 1.0.0, a minor release could make breaking changes, so upgrade in steps. From 1.0.0 on, upgrades follow the rules in Versioning and support.

Upgrade step by step

These versions made breaking changes. Start at the first one that is newer than your version. At each one, install it, read its release notes, and change your code as they say before you go on to the next:

Once you are on 0.153.0, upgrade to 1.x: 1.0.0 has no breaking changes compared with 0.153.0.

The release notes list the changes in each version.

Pre-v0.100 static files

When you upgrade to v0.100 or later, remove safer_staticfiles as Migrating from safer_staticfiles shows. From v0.100 on, django-components keeps your Python and HTML component files off your static file server (see Security notes).

If you stay on an older release: before v0.100, django.contrib.staticfiles treated every file the same, so your .py and .html files could end up on your static file server. That exposes your backend logic, a potential security vulnerability.

From v0.27 until v0.100, django-components shipped with an additional installable app, django_components.safer_staticfiles. It was a drop-in replacement for django.contrib.staticfiles that behaves the same, except it ignores .py and .html files, so these do not end up on your static file server.

To use it, add it to INSTALLED_APPS and remove django.contrib.staticfiles:

INSTALLED_APPS = [
    # 'django.contrib.staticfiles',   # <-- REMOVE
    'django_components',
    'django_components.safer_staticfiles'  # <-- ADD
]

If you are on a pre-v0.27 version of django-components, you can instead:

  • pass --ignore <pattern> options to the collectstatic command, or
  • subclass Django's StaticFilesConfig and set ignore_patterns.

The official docs of the staticfiles app describe both routes.

safer_staticfiles filters only the collectstatic command:

python manage.py collectstatic

It does not filter the development server:

python manage.py runserver