Add MANIFEST file and update README file

This commit is contained in:
Uğur Özyılmazel
2019-10-11 13:37:19 +03:00
parent cd86540a90
commit 0a200f450f
3 changed files with 127 additions and 8 deletions
+2
View File
@@ -0,0 +1,2 @@
recursive-include djaa_list_filter/static *
recursive-include djaa_list_filter/templates *
+122 -5
View File
@@ -1,14 +1,120 @@
![Python](https://img.shields.io/badge/python-3.7.3-green.svg)
![Django](https://img.shields.io/badge/django-2.2.6-green.svg)
![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)
[![PyPI version](https://badge.fury.io/py/django-admin-autocomplete-list-filter.svg)](https://badge.fury.io/py/django-admin-autocomplete-list-filter)
# django-admin-autocomplete-list-filter
Ajax autocomplete list filter for Django admin. Uses built-in shipped Djangos
widgets.
Ajax autocomplete list filter helper for Django admin. Uses Djangos built-in
autocomplete widget! No extra package or install required!
| Before | After |
|:-------|:------|
| ![Before django-admin-autocomplete-list-filter](screenshots/before.png "Before...") | ![After django-admin-autocomplete-list-filter](screenshots/after.png "After...") |
## Installation and Usage
@wip
```bash
$ pip install django-admin-autocomplete-list-filter
```
Add `djaa_list_filter` to `INSTALLED_APPS` in your `settings.py`:
```python
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'djaa_list_filter',
]
```
Now, lets look at this example model:
```python
# models.py
from django.conf import settings
from django.db import models
class Post(models.Model):
category = models.ForeignKey(to='Category', on_delete=models.CASCADE, related_name='posts')
author = models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='posts')
title = models.CharField(max_length=255)
body = models.TextField()
tags = models.ManyToManyField(to='Tag', blank=True)
def __str__(self):
return self.title
class Category(models.Model):
title = models.CharField(max_length=255)
def __str__(self):
return self.title
class Tag(models.Model):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
```
We have 2 **ForeignKey** fields and one **ManyToManyField** to enable
autocomplete list filter feature on admin. All you need is to inherit from
`AjaxAutocompleteListFilterModelAdmin` which inherits from Djangos
`admin.ModelAdmin`.
Now we have an extra ModelAdmin method: `autocomplete_list_filter`. Uses
Django Admins `search_fields` logic. You need to enable `search_fields`
in the related ModelAdmin. To enable completion on `Category` relation,
`CategoryAdmin` should have `search_fields` thats it!
```python
from django.contrib import admin
from djaa_list_filter.admin import (
AjaxAutocompleteListFilterModelAdmin,
)
from .models import Category, Post, Tag
@admin.register(Post)
class PostAdmin(AjaxAutocompleteListFilterModelAdmin):
list_display = ('__str__', 'author', 'show_tags')
autocomplete_list_filter = ('category', 'author', 'tags')
def show_tags(self, obj):
return ' , '.join(obj.tags.values_list('name', flat=True))
@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
search_fields = ['title']
ordering = ['title']
@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
search_fields = ['name']
ordering = ['name']
```
## Development
You are very welcome to contribute, fix bugs or improve this project. We
hope to help people who needs this feature. We made this package for
our company project. Good appetite for all the Django developers out there!
## License
@@ -18,8 +124,9 @@ This project is licensed under MIT
## Contributer(s)
* [Can Adıyaman](https://github.com/canadiyaman) - Creator, maintainer
* [Uğur "vigo" Özyılmazel](https://github.com/vigo) - Maintainer
* [Uğur "vigo" Özyılmazel](https://github.com/vigo) - Author, Maintainer
* [Can Adıyaman](https://github.com/canadiyaman) - Author, Maintainer
* [Erdi Mollahüseyinoğlu](https://github.com/erdimollahuseyin) - Author, Maintainer
---
@@ -35,8 +142,18 @@ All PRs are welcome!
---
## TODO
- Add unit tests
- Improve JavaScript code :)
## Change Log
**2019-10-11**
- Add ManyToManyField support
- Initial release
**2019-10-07**
- Init repo...
+3 -3
View File
@@ -14,8 +14,8 @@ setup(
long_description=README,
long_description_content_type='text/markdown',
url='https://github.com/demiroren-teknoloji/django-admin-autocomplete-list-filter',
author='Uğur Özyılmazel, Can Adıyaman',
author_email='ugur.ozyilmazel@demirorenteknoloji.com, can.adiyaman@demirorenteknoloji.com',
author='Demirören Teknoloji Django Team',
author_email='account@demirorenteknoloji.com',
license='MIT',
python_requires='>=3.0',
packages=find_packages(),
@@ -23,7 +23,7 @@ setup(
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 2.2.4',
'Framework :: Django :: 2.2',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',