{"id":8025,"library":"collectfast","title":"Collectfast: A Faster Collectstatic for Django","description":"Collectfast dramatically speeds up Django's `collectstatic` command when using cloud storage by only uploading static files that have changed. It leverages MD5 hashes (ETags) or modification times to determine if a file needs to be re-uploaded. The current version is 2.2.0, with a release cadence of a few times per year, focusing on compatibility and performance improvements.","status":"active","version":"2.2.0","language":"en","source_language":"en","source_url":"https://github.com/antonagestam/collectfast/","tags":["django","static-files","collectstatic","s3","cloud-storage","performance"],"install":[{"cmd":"pip install collectfast","lang":"bash","label":"Install collectfast"}],"dependencies":[{"reason":"Collectfast is a Django app for speeding up static file collection.","package":"Django","optional":false},{"reason":"Required for most cloud storage backends (e.g., S3, GCS) which collectfast aims to optimize.","package":"django-storages","optional":true},{"reason":"Required by django-storages when using AWS S3 storage backend.","package":"boto3","optional":true}],"imports":[{"note":"Used for creating custom strategies or extending existing ones, especially for implementing custom hooks like `post_copy_hook` or `on_skip_hook` introduced in 2.2.0.","symbol":"Strategy","correct":"from collectfast.strategies.base import Strategy"}],"quickstart":{"code":"import os\n\n# settings.py\n\n# Add collectfast to your INSTALLED_APPS\nINSTALLED_APPS = [\n    # ... other apps\n    'collectfast',\n    'storages', # if using django-storages\n]\n\n# Enable Collectfast\nCOLLECTFAST_ENABLED = True\n\n# Explicitly set the strategy (required since collectfast 2.0.0)\n# Choose the strategy that matches your STATICFILES_STORAGE backend\n# For AWS S3 with django-storages s3boto3 backend:\nCOLLECTFAST_STRATEGY = 'collectfast.strategies.aws.S3Strategy'\n\n# Configure your STATICFILES_STORAGE (example for AWS S3 with django-storages)\nAWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID', 'your_access_key')\nAWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY', 'your_secret_key')\nAWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME', 'your-bucket-name')\nAWS_S3_REGION_NAME = os.environ.get('AWS_S3_REGION_NAME', 'us-east-1')\nAWS_S3_SIGNATURE_VERSION = 's3v4'\nAWS_S3_FILE_OVERWRITE = False\nAWS_DEFAULT_ACL = None # Or 'public-read' if files should be publicly accessible\n\nSTATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'\nSTATIC_URL = f\"https://{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com/\"\n\n# Define STATIC_ROOT for local collectstatic (even if collectfast bypasses it for cloud storage)\nSTATIC_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'staticfiles')","lang":"python","description":"To quickly set up `collectfast`, add it to your `INSTALLED_APPS` and configure the necessary settings in your Django `settings.py`. Ensure `COLLECTFAST_ENABLED` is `True` and, crucially, set `COLLECTFAST_STRATEGY` to match your static files storage backend. This example shows configuration for AWS S3 using `django-storages`."},"warnings":[{"fix":"Upgrade Python to 3.6+ and Django to 2.0+. If using S3, ensure `django-storages` is configured with `S3Boto3Storage` and `COLLECTFAST_STRATEGY` is set to `collectfast.strategies.aws.S3Strategy`.","message":"`collectfast` 2.0.0 dropped support for Python 3.5 and Django 1.11. It also removed the `boto` strategy (`collectfast.strategies.boto.BotoStrategy`), requiring migration to `boto3` strategies for S3.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Add `COLLECTFAST_STRATEGY = 'collectfast.strategies.aws.S3Strategy'` (or other relevant strategy, e.g., `collectfast.strategies.filesystem.FileSystemStrategy`) to your `settings.py`.","message":"Starting with `collectfast` 2.0.0, the `COLLECTFAST_STRATEGY` setting must be explicitly defined in your Django `settings.py` as automatic strategy guessing was removed.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Migrate to `collectfast.strategies.aws.S3Strategy` (for `boto3`) and ensure `django-storages` is configured with `S3Boto3Storage`.","message":"`collectfast.strategies.boto.BotoStrategy` was deprecated in version 1.3.0 and completely removed in 2.0.0. Using this strategy will result in errors.","severity":"deprecated","affected_versions":"1.3.0 - 2.x"},{"fix":"Upgrade `collectfast` to 2.2.0 or later to ensure consistent gzip compression levels for S3.","message":"Prior to `collectfast` 2.2.0, there was a bug where gzip compression level for static files was inconsistent with S3's default handling, potentially causing issues with served content if not explicitly managed.","severity":"gotcha","affected_versions":"<2.2.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install collectfast` to install the package.","cause":"The `collectfast` package is not installed in the active Python environment.","error":"ModuleNotFoundError: No module named 'collectfast'"},{"fix":"Add `COLLECTFAST_STRATEGY = 'collectfast.strategies.aws.S3Strategy'` (or the appropriate strategy for your setup) to your Django `settings.py`.","cause":"Since version 2.0.0, collectfast requires an explicit strategy to be set, as automatic guessing was removed.","error":"ImproperlyConfigured: COLLECTFAST_STRATEGY setting is required."},{"fix":"Ensure `STATICFILES_STORAGE` is set to a supported backend (e.g., `storages.backends.s3boto3.S3Boto3Storage`) and `COLLECTFAST_STRATEGY` is correctly configured for it (e.g., `'collectfast.strategies.aws.S3Strategy'` for S3).","cause":"The `STATICFILES_STORAGE` backend you have configured either does not have a corresponding `collectfast` strategy, or `COLLECTFAST_STRATEGY` is incorrectly configured for it.","error":"ImproperlyConfigured: collectfast doesn't support your storage backend"},{"fix":"Migrate your `STATICFILES_STORAGE` to `storages.backends.s3boto3.S3Boto3Storage` and update `COLLECTFAST_STRATEGY` to `collectfast.strategies.aws.S3Strategy` to use `boto3`.","cause":"This typically occurs when using the older `storages.backends.s3boto.S3BotoStorage` with `collectfast` 2.0.0+, which removed support for the `boto` library and its associated strategy.","error":"AttributeError: 'S3BotoStorage' object has no attribute 'bucket_name' (or similar errors related to `boto`)"}]}