{"id":21919464,"url":"https://github.com/dlrsp/django-custom-storage","last_synced_at":"2025-09-07T21:14:03.930Z","repository":{"id":212246361,"uuid":"695837655","full_name":"DLRSP/django-custom-storage","owner":"DLRSP","description":"Django application provide custom storage uses S3 and Compressor","archived":false,"fork":false,"pushed_at":"2025-07-07T11:12:35.000Z","size":748,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-25T07:21:09.739Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DLRSP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-09-24T11:39:08.000Z","updated_at":"2025-04-26T08:10:25.000Z","dependencies_parsed_at":"2024-01-23T09:58:58.486Z","dependency_job_id":"d1d7288e-f2c9-4939-94eb-829dfdef9386","html_url":"https://github.com/DLRSP/django-custom-storage","commit_stats":null,"previous_names":["dlrsp/django-custom-storage"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/DLRSP/django-custom-storage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-custom-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-custom-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-custom-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-custom-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DLRSP","download_url":"https://codeload.github.com/DLRSP/django-custom-storage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DLRSP%2Fdjango-custom-storage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274095919,"owners_count":25221536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T20:08:07.254Z","updated_at":"2025-09-07T21:14:03.885Z","avatar_url":"https://github.com/DLRSP.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-custom-storage [![PyPi license](https://img.shields.io/pypi/l/django-custom-storage.svg)](https://pypi.python.org/pypi/django-custom-storage)\n\n[![PyPi status](https://img.shields.io/pypi/status/django-custom-storage.svg)](https://pypi.python.org/pypi/django-custom-storage)\n[![PyPi version](https://img.shields.io/pypi/v/django-custom-storage.svg)](https://pypi.python.org/pypi/django-custom-storage)\n[![PyPi python version](https://img.shields.io/pypi/pyversions/django-custom-storage.svg)](https://pypi.python.org/pypi/django-custom-storage)\n[![PyPi downloads](https://img.shields.io/pypi/dm/django-custom-storage.svg)](https://pypi.python.org/pypi/django-custom-storage)\n[![PyPi downloads](https://img.shields.io/pypi/dw/django-custom-storage.svg)](https://pypi.python.org/pypi/django-custom-storage)\n[![PyPi downloads](https://img.shields.io/pypi/dd/django-custom-storage.svg)](https://pypi.python.org/pypi/django-custom-storage)\n\n## GitHub ![GitHub release](https://img.shields.io/github/tag/DLRSP/django-custom-storage.svg) ![GitHub release](https://img.shields.io/github/release/DLRSP/django-custom-storage.svg)\n\n## Test [![codecov.io](https://codecov.io/github/DLRSP/django-custom-storage/coverage.svg?branch=main)](https://codecov.io/github/DLRSP/django-custom-storage?branch=main) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/DLRSP/django-custom-storage/main.svg)](https://results.pre-commit.ci/latest/github/DLRSP/django-custom-storage/main) [![gitthub.com](https://github.com/DLRSP/django-custom-storage/actions/workflows/ci.yaml/badge.svg)](https://github.com/DLRSP/django-custom-storage/actions/workflows/ci.yaml)\n\n## Check Demo Project\n* Check the demo repo on [GitHub](https://github.com/DLRSP/example/tree/django-custom-storage)\n\n## Requirements\n-   Python 3.8+ supported.\n-   Django 3.2+ supported.\n\n## Setup\n1. Install from **pip**:\n```shell\npip install django-custom-storage\n```\n\n2. Modify `settings.py` by adding the app to `INSTALLED_APPS`:\n```python\nINSTALLED_APPS = [\n    # ...\n    \"compressor\",\n    \"custom_storage\",\n    # ...\n]\n```\n\n3. Finally, Modify `settings.py` by adding the needed configurations:\n```python\n# ...other setting...\n# Media files (Uploaded Images, Documents, Video, Audio)\nMEDIA_ROOT = '/var/opt/your_project_name/mediaroot/'\n# Static files (Fonts, CSS, JavaScript, Icons, Theme's Images)\nSTATIC_URL = '/static/'\nSTATIC_ROOT = '/var/cache/your_project_name/staticroot/'\n\n# Example: cdn.your_project_bucket_name.com\nAWS_STORAGE_BUCKET_PREFIX = \"cdn\"\nAWS_STORAGE_BUCKET_NAME = \"your_project_bucket_name\"\nAWS_STORAGE_BUCKET_TLD = \"com\"\n\n# Access Key ID \u0026 Secret Access Key\nAWS_ACCESS_KEY_ID = 'YOUR_PROJECT_AWS_ACCESS_KEY_ID'\nAWS_SECRET_ACCESS_KEY = 'YOUR_PROJECT_AWS_SECRET_ACCESS_KEY'\n# ...other setting...\n\n# START - Compress and Upload on S3\nimport os\nimport sys\nimport datetime\n\n# Add option to FORCE_LOCAL_STORAGE\n# https://www.mslinn.com/django/1300-django-aws-control.html\nif \"--force-local-storage\" in sys.argv:\n    print(\"AWS datastore disabled; using local storage for assets instead.\")\n    FORCE_LOCAL_STORAGE = True\n    sys.argv.remove(\"--force-local-storage\")\nelse:\n    print(\"Using AWS datastore for assets.\")\n    FORCE_LOCAL_STORAGE = False\n\nif not FORCE_LOCAL_STORAGE:\n    DEFAULT_FILE_STORAGE = 'custom_storage.storage.MediaRootCachedS3Storage'\n    if not os.getenv('RUN_COMPRESS', False):\n        STATICFILES_STORAGE = 'custom_storage.storage.StaticRootCachedS3Storage'\nelse:\n    DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'\n    \nCOMPRESS_ENABLED = True\nCOMPRESS_OFFLINE = True\n\nSTATICFILES_FINDERS = (\n    'django.contrib.staticfiles.finders.FileSystemFinder',\n    'django.contrib.staticfiles.finders.AppDirectoriesFinder',\n    'compressor.finders.CompressorFinder',\n)\nCOMPRESS_ROOT = STATIC_ROOT\n\nAWS_S3_CUSTOM_DOMAIN = f\"{AWS_STORAGE_BUCKET_PREFIX}.{AWS_STORAGE_BUCKET_NAME}.{AWS_STORAGE_BUCKET_TLD}\"\n\nSTATIC_URL = f\"https://{AWS_S3_CUSTOM_DOMAIN}/static/\"\nMEDIA_URL = f\"https://{AWS_S3_CUSTOM_DOMAIN}/media/\"\n\nAWS_DEFAULT_ACL = 'public-read'\nAWS_QUERYSTRING_AUTH = False\nAWS_FILE_EXPIRE = 200\nAWS_PRELOAD_METADATA = True\n\ntwo_months = datetime.timedelta(days=61)\ndate_two_months_later = datetime.date.today() + two_months\nexpires = date_two_months_later.strftime(\"%A, %d %B %Y 20:00:00 GMT\")\nAWS_S3_OBJECT_PARAMETERS = {\n    'Expires': expires,\n    'CacheControl': 'max-age=%d' % (int(two_months.total_seconds()),),\n}\n\nCOMPRESS_CSS_HASHING_METHOD = None\nCOMPRESS_CSS_FILTERS = [\n    'compressor.filters.css_default.CssAbsoluteFilter',\n    # 'compressor.filters.css_default.CssRelativeFilter',\n    'compressor.filters.cssmin.CSSMinFilter'\n]\nCOMPRESS_JS_FILTERS = [\n    'compressor.filters.jsmin.JSMinFilter',\n]\n\nCOMPRESS_OUTPUT_DIR = 'compressed_static'\nCOMPRESS_STORAGE = 'custom_storage.storage.StaticRootCachedS3Storage'\n# END - Compress and Upload on S3\n\n```\n\n\n## Run Example Project\n\n```shell\ngit clone --depth=50 --branch=django-custom-storage https://github.com/DLRSP/example.git DLRSP/example\ncd DLRSP/example\npython manage.py runserver\n```\n\nNow browser the app @ http://127.0.0.1:8000\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlrsp%2Fdjango-custom-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlrsp%2Fdjango-custom-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlrsp%2Fdjango-custom-storage/lists"}