{"id":25732426,"url":"https://github.com/vigo/django-admin-list-filter","last_synced_at":"2025-04-09T18:16:22.898Z","repository":{"id":240693215,"uuid":"803377470","full_name":"vigo/django-admin-list-filter","owner":"vigo","description":"Dead simple autocompletion for Django admin `list_filter`.","archived":false,"fork":false,"pushed_at":"2025-03-14T18:05:14.000Z","size":9798,"stargazers_count":32,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T16:50:23.089Z","etag":null,"topics":["django","django-admin","django-admin-filters"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/dalf/","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/vigo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"vigo","patreon":"vigoo"}},"created_at":"2024-05-20T15:52:40.000Z","updated_at":"2025-03-30T07:30:31.000Z","dependencies_parsed_at":"2024-05-20T16:49:54.200Z","dependency_job_id":"566bdce7-a3f1-4ab4-9753-e5461ee335f6","html_url":"https://github.com/vigo/django-admin-list-filter","commit_stats":null,"previous_names":["vigo/django-admin-list-filter"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vigo%2Fdjango-admin-list-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vigo%2Fdjango-admin-list-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vigo%2Fdjango-admin-list-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vigo%2Fdjango-admin-list-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vigo","download_url":"https://codeload.github.com/vigo/django-admin-list-filter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085322,"owners_count":21045139,"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","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":["django","django-admin","django-admin-filters"],"created_at":"2025-02-26T03:40:59.220Z","updated_at":"2025-04-09T18:16:22.880Z","avatar_url":"https://github.com/vigo.png","language":"Python","funding_links":["https://github.com/sponsors/vigo","https://patreon.com/vigoo"],"categories":[],"sub_categories":[],"readme":"![Version](https://img.shields.io/badge/version-0.3.0-orange.svg?style=for-the-badge\u0026logo=semver)\n![Python](https://img.shields.io/badge/python-3.11+-green.svg?style=for-the-badge\u0026logo=python)\n![Django](https://img.shields.io/badge/django-5.0.2-green.svg?style=for-the-badge\u0026logo=django)\n[![Ruff](https://img.shields.io/endpoint?style=for-the-badge\u0026url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![PyPI version](https://img.shields.io/pypi/v/dalf.svg?style=for-the-badge\u0026logo=pypi)](https://pypi.org/project/dalf/)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/dalf?style=for-the-badge\u0026logo=pypi)\n[![Codecov](https://img.shields.io/codecov/c/github/vigo/django-admin-list-filter?token=6JRNSB6WN1\u0026style=for-the-badge\u0026logo=codecov)](https://codecov.io/gh/vigo/django-admin-list-filter)\n\n\n# Django Admin List Filter\n\nDead simple autocompletion for Django admin `list_filter`. This was made using\nthe libraries shipped with Django (`select2`, `jquery`), Django’s built-in\nlist filters, and Django’s built-in `AutocompleteJsonView`.\n\nThis package is an **improved** version of the previously created \n[django-admin-autocomplete-list-filter][1] package. It supports Django **version 5** and \nabove. Please note that the *django-admin-autocomplete-list-filter* package is \nnow **deprecated**. Since I am no longer part of the organization where it was \ninitially developed, I cannot archive it.\n\nNo extra package or install required!\n\nBefore **Django Admin List Filter**\n\n![Before Django Admin List Filter](screens/before-dalf.gif)\n\nAfter **Django Admin List Filter**\n\n![After Django Admin List Filter](screens/after-dalf.gif?1)\n\n---\n\n## 2024-07-03\n\nThanks to my dear friend [Bahattin Çiniç][bahattincinic]’s warning, He realized\nthat the necessary HTML, CSS, and JavaScript files were missing from the\npublished package! I quickly fixed this and published a new version. The `0.1.0`\nversion is a faulty version. I apologize to the users for this confusion.\nThank you. - vigo\n\n---\n\n## Installation\n\n```bash\npip install dalf\n```\n\nAdd `dalf` to your `INSTALLED_APPS` in your `settings.py`:\n\n```python\nINSTALLED_APPS = [\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.messages\",\n    \"django.contrib.staticfiles\",\n    \"dalf\", # \u003c- add\n]\n```\n\n---\n\n## Usage\n\nUse `DALFModelAdmin`, inherited from `admin.ModelAdmin` to inject media urls only.\nYou have some filters;\n\n- `DALFRelatedField`: inherited from `admin.RelatedFieldListFilter`.\n- `DALFRelatedFieldAjax`: inherited from `admin.RelatedFieldListFilter`\n- `DALFRelatedOnlyField`: inherited from `admin.RelatedOnlyFieldListFilter`.\n- `DALFChoicesField`: inherited from `admin.ChoicesFieldListFilter`.\n\nExample `models.py`\n\n```python\n# models.py\nimport uuid\n\nfrom django.conf import settings\nfrom django.db import models\n\n\nclass Category(models.Model):\n    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)\n    title = models.CharField(max_length=255)\n\n    def __str__(self):\n        return self.title\n\n\nclass Tag(models.Model):\n    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)\n    name = models.CharField(max_length=255)\n\n    def __str__(self):\n        return self.name\n\n\nclass Post(models.Model):\n    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)\n    category = models.ForeignKey(to='Category', on_delete=models.CASCADE, related_name='posts')\n    author = models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='posts')\n    title = models.CharField(max_length=255)\n    body = models.TextField()\n    tags = models.ManyToManyField(to='Tag', blank=True)\n\n    def __str__(self):\n        return self.title\n```\n\nExample `admin.py`:\n\n```python\n# admin.py\nfrom dalf.admin import DALFModelAdmin, DALFRelatedOnlyField, DALFRelatedFieldAjax\nfrom django.contrib import admin\nfrom YOURAPP.models import Post\n\n@admin.register(Post)\nclass PostAdmin(DALFModelAdmin):\n    list_filter = (\n        ('author', DALFRelatedOnlyField),    # if author has a post!\n        ('category', DALFRelatedFieldAjax),  # enable ajax completion for category field (FK)\n        ('tags', DALFRelatedFieldAjax),      # enable ajax completion for tags field (M2M)\n    )\n```\n\nThat’s all... There is also `DALFChoicesField`, you can test it out:\n\n```python\n# admin.py\nfrom django.contrib import admin\nfrom django.contrib.auth.admin import UserAdmin as BaseUserAdmin\nfrom django.contrib.auth.models import User\n\nfrom dalf.admin import (\n    DALFModelAdmin,\n    DALFChoicesField,\n    DALFRelatedOnlyField,\n    DALFRelatedFieldAjax,\n)\n\nfrom YOURAPP.models import Post, Category, Tag\n\n# must be registered, must have search_fields, required for `author` field demo.\n# this is demo purpose only, you can register/import your own/custom User model\nclass UserAdmin(BaseUserAdmin):\n    search_fields = ['username']\n    ordering = ['username']\n\nadmin.site.unregister(User)\nadmin.site.register(User, UserAdmin)\n\n@admin.register(Post)\nclass PostAdmin(DALFModelAdmin):\n    list_filter = (\n        ('author', DALFChoicesField),        # enable autocomplete w/o ajax (FK)\n        ('category', DALFRelatedFieldAjax),  # enable ajax completion for category field (FK)\n        ('tags', DALFRelatedOnlyField),      # enable ajax completion for tags field (M2M) if posts has any tag!\n    )\n\n# must be registered, must have search_fields\n@admin.register(Category)\nclass CategoryAdmin(admin.ModelAdmin):\n    search_fields = ['title',]\n    ordering = ['title']\n\n\n# must be registered, must have search_fields\n@admin.register(Tag)\nclass TagAdmin(admin.ModelAdmin):\n    search_fields = ['name',]\n    ordering = ['name']\n\n```\n\n### Extras\n\nI mostly use `django-timezone-field`, here is an illustration of timezone\ncompletion w/o **ajax**:\n\n```bash\npip install django-timezone-field\n```\n\nNow add `timezone` field to `Post` model:\n\n```python\n# modify models.py, add new ones\n# ...\n\nfrom timezone_field import TimeZoneField                 # \u003c- add this line\n\nclass Post(models.Model):\n    # all the other fiels\n    timezone = TimeZoneField(default=settings.TIME_ZONE) # \u003c- add this line\n    \n    # rest of the code\n```\n\nNow, just add `timezone` as regular `list_filter`:\n\n```python\n# modify admin.py, add new ones\n\n@admin.register(Post)\nclass PostAdmin(DALFModelAdmin):\n    # previous codes\n    list_filter = (\n        # previous filters\n        ('timezone', DALFChoicesField), # \u003c- add this line\n    )\n```\n\nThat’s it!\n\n---\n\n## Contributor(s)\n\n* [Uğur Özyılmazel](https://github.com/vigo) - Creator, maintainer\n* [Ehco](https://github.com/Ehco1996) - Contributor\n* [Bahattin Çiniç][bahattincinic] - Contributor\n* [Nguyễn Hồng Quân](https://github.com/hongquan) - Contributor\n* [Stanislav Terliakov](https://github.com/sterliakov) - Contributor\n\n---\n\n## Contribute\n\nAll PR’s are welcome!\n\n1. `fork` (https://github.com/vigo/django-admin-list-filter/fork)\n1. Create your `branch` (`git checkout -b my-feature`)\n1. `commit` yours (`git commit -am 'add some functionality'`)\n1. `push` your `branch` (`git push origin my-feature`)\n1. Than create a new **Pull Request**!\n\nI am not very proficient in JavaScript. Therefore, any support, suggestions,\nand feedback are welcome to help improve the project. Feel free to open\npull requests!\n\n---\n\n## Development\n\nClone the repo somewhere, and install with:\n\n```bash\npip install -r requirements-dev.txt\npip install -e /path/to/dalf\npre-commit install\n```\n\nAnd play with the filters :)\n\n## Publish\n\nNote to my self:\n\n```bash\npip install build twine\nrake -T\n\nrake build           # Build package\nrake bump[revision]  # Bump version: major,minor,patch\nrake clean           # Remove/Delete build..\nrake test            # Run tests\nrake upload:main     # Upload package to main distro (release)\nrake upload:test     # Upload package to test distro\n```\n\n---\n\n## Change Log\n\n**2025-03-14**\n\n- Fix ForeignKey relation to `__id` issue. [Stanislav Terliakov](https://github.com/sterliakov)\n\n**2024-11-07**\n\n- Fix dark-mode ajax autocompletion colors - [Nguyễn Hồng Quân](https://github.com/hongquan)\n\n**2024-09-06**\n\n- Fix dark-mode text color.\n\n---\n\n**2024-08-25**\n\n- Fix extend media in `DALFModelAdmin` without overriding default assets - [Bahattin][bahattincinic]\n\n---\n\n**2024-08-16**\n\n- Add `gettextSafe` function to handle missing gettext in Django - [Bahattin][bahattincinic]\n\n---\n\n**2024-07-14**\n\n- Fix choice.display last element issue\n\n---\n\n**2024-07-03**\n\n- Now package is working fine :) Thanks to [Bahattin][bahattincinic]!\n\n---\n\nYou can read the whole story [here][changelog].\n\n---\n\n## License\n\nThis project is licensed under MIT\n\n---\n\nThis project is intended to be a safe, welcoming space for collaboration, and\ncontributors are expected to adhere to the [code of conduct][coc].\n\n[1]: https://github.com/demiroren-teknoloji/django-admin-autocomplete-list-filter \"Deprecated, old package\"\n[coc]: https://github.com/vigo/django-admin-list-filter/blob/main/CODE_OF_CONDUCT.md\n[changelog]: https://github.com/vigo/django-admin-list-filter/blob/main/CHANGELOG.md\n[bahattincinic]: https://github.com/bahattincinic\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvigo%2Fdjango-admin-list-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvigo%2Fdjango-admin-list-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvigo%2Fdjango-admin-list-filter/lists"}