{"id":34248366,"url":"https://github.com/knifecake/django-anchor","last_synced_at":"2025-12-16T08:09:44.769Z","repository":{"id":248984139,"uuid":"830242824","full_name":"knifecake/django-anchor","owner":"knifecake","description":"Attach files to Django models, inspired by Ruby on Rails' Active Storage.","archived":false,"fork":false,"pushed_at":"2025-09-03T15:56:42.000Z","size":425,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-25T05:20:59.770Z","etag":null,"topics":["attachments","django","files","storage"],"latest_commit_sha":null,"homepage":"https://django-anchor.readthedocs.io/en/latest/","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/knifecake.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-17T22:17:49.000Z","updated_at":"2025-09-03T15:56:46.000Z","dependencies_parsed_at":"2024-12-11T20:27:29.465Z","dependency_job_id":"18483fe9-7e4b-40c3-9539-7780eea90f30","html_url":"https://github.com/knifecake/django-anchor","commit_stats":null,"previous_names":["knifecake/django-anchor"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/knifecake/django-anchor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knifecake%2Fdjango-anchor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knifecake%2Fdjango-anchor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knifecake%2Fdjango-anchor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knifecake%2Fdjango-anchor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knifecake","download_url":"https://codeload.github.com/knifecake/django-anchor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knifecake%2Fdjango-anchor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27761344,"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-12-16T02:00:10.477Z","response_time":57,"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":["attachments","django","files","storage"],"created_at":"2025-12-16T08:09:44.226Z","updated_at":"2025-12-16T08:09:44.762Z","avatar_url":"https://github.com/knifecake.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Anchor\n\n[![Test](https://github.com/knifecake/django-anchor/actions/workflows/test.yml/badge.svg)](https://github.com/knifecake/django-anchor/actions/workflows/test.yml)\n[![Documentation Status](https://readthedocs.org/projects/django-anchor/badge/?version=latest)](https://django-anchor.readthedocs.io/en/latest/?badge=latest)\n\nDjango Anchor is a reusable Django app that allows you to attach files to models.\n\nAnchor works very similarly to Django's ``FileField`` and ``ImageField`` model\nfields, but adds a few extra features:\n\n- Images can be resized, converted to another format and otherwise transformed.\n- Files are served through signed URLs that can expire after a configurable\n  amount of time, even when using the default file-system storage backend.\n\nDjango Anchor is essentially a port of the excellent [Active\nStorage](https://edgeguides.rubyonrails.org/active_storage_overview.html) Ruby\non Rails feature, but leveraging existing Django abstractions and packages of\nthe Python ecosystem. Some features are not yet implemented, but the core\nconcepts are there two eventually be able to support them.\n\n## Installation\n\nCheck out the [installation\nguide](https://django-anchor.readthedocs.io/en/latest/installation.html) in the\ndocumentation for more details.\n\nDjango-anchor is compatible with Django \u003e= 4.2 and Python \u003e= 3.11.\n\n1. Add the `django-anchor` package to your dependencies. You can do this by\n   running:\n\n       pip install django-anchor\n\n   or by adding `django-anchor` to your `requirements.txt` or `pyproject.toml`\n   files if you have one.\n\n2. Add  `anchor` to `settings.INSTALLED_APPS`\n\n3. Add URL configuration to your project:\n\n   ```python\n   urlpatterns = [\n       path('anchor/', include('anchor.urls')),\n   ]\n   ```\n\n4. Run migrations:\n\n   ```bash\n   python manage.py migrate\n   ```\n\nIn addition, if you wish to create image variants, a Pillow \u003e= 9.5 should be\navailable in your system.\n\n## Usage\n\n💡 Check out the [dummy](./tests/dummy//) Django project in the test folder for\ninspiration and the [Getting Started\nguide](https://django-anchor.readthedocs.io/en/latest/getting_started.html) in\nthe documentation.\n\n### Adding files to models\n\nThe easiest way to add a file to a model is to add a `BlobField` to it:\n\n```python\nfrom django.db import models\nfrom anchor.models.fields import SingleAttachmentField\n\n\nclass Movie(models.Model):\n    title = models.CharField(max_length=100)\n\n    cover = SingleAttachmentField()\n```\n\nThat's it! No need to run ``makemigrations`` or ``migrate`` since Django Anchor\ndoesn't actually need any columns added to the model.\n\nThe ``cover`` field works just like any other model field:\n\n```python\n# Create a new movie\nmovie = Movie.objects.create(title=\"My Movie\")\n\n# Attach an uploaded file\nmovie.cover = uploaded_file\n\n# Get a URL to the file\nmovie.cover.url()\n\n# Get a URL to a miniature version of the file\nmovie.cover.representation(resize_to_fit=(200, 200), format=\"webp\").url()\n\n# Delete the cover and remove the file from storage\nmovie.cover.purge()\n```\n\n### Using files in templates\n\nDjango anchor comes with a handy template tag to render URLs of files you've stored:\n\n```\n{% load anchor %}\n\u003cimg src=\"{% representation_url movie.cover resize_to_fit='300x600' format='jpeg' %}\"\u003e\n```\n\nThe above call to `representation_url` will generate an optimized version of the\nmovie's cover in JPEG format which fits inside a 300x600 rectangle.\n\n## Contributing\n\nPRs and issues are very welcome!\n\nCheck out [CONTRIBUTING.md](./CONTRIBUTING.md) to learn how to set up the\nproject locally.\n\n## License\n\nThis project is released under the MIT License. Check out\n[LICENSE](./LICENSE.md) to get the full text of the license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknifecake%2Fdjango-anchor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknifecake%2Fdjango-anchor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknifecake%2Fdjango-anchor/lists"}