# django-fastadmin

django admin extensions.

## Install

```shell
pip install django-fastadmin
```

## Usage

**pro/settings.py**

```
INSTALLED_APPS = [
    ...
    "django_static_jquery3",
    "django_static_ace_builds",
    "django_apiview",
    'django_fastadmin',
    ...
]
```

- Add dependence package names in INSTALLED_APPS.


## Installed Admin Extensions

### Admin extends

- UuidFieldSearchableAdmin
- InlineBooleanFieldsAllowOnlyOneCheckedMixin
- InlineUniqueChoiceFieldsMixin # @todo
- DisableDeleteActionMixin
- InlineEditingHideOriginalMixin
- DisableInlineEditingInAddingMixin
- DisableAddPermissionMixin
- DisableDeletePermissionMixin
- DisableChangePermissionMixin
- MarkPermissionsMixin
- TextFieldAutoHeightMixin
- TextFieldSetRowColumnMixin
- ResetToRandomPasswordField
- EditablePasswordField
- HideShowField
- AddAdminViewHelper
- ToggleFieldStateAdmin
- SetTopModelAdmin
- DjangoAdminGlobalMedia
- DjangoWithExtraContextAdmin
- DjangoDynamicMediaAdmin
- HiddenFieldsAdmin
- HideShowFieldsOnValueAdmin

### Widgets

- AceWidget
- TitleToCodeWidget

### Services

- SimpleTaskService

### Forms

### Filters


## admin.InlineBooleanFieldsAllowOnlyOneCheckedMixin Usage

- `django_static_jquery3` required in INSTALLED_APPS.
- Add this mixin to inline class, and put it before TabularInline.
- Add classes property
    - Add class InlineBooleanFieldsAllowOnlyOneCheckedMixin.special_class_name
    - Add class InlineBooleanFieldsAllowOnlyOneCheckedMixin.field_name_prefix + {field name},
- Example:
    ```
    from django.contrib import admin
    from django_fastadmin.admin import InlineBooleanFieldsAllowOnlyOneCheckedMixin

    from .models import Book
    from .models import Category

    class BookInline(InlineBooleanFieldsAllowOnlyOneCheckedMixin, admin.TabularInline):
        model = Book
        extra = 0
        classes = [
            InlineBooleanFieldsAllowOnlyOneCheckedMixin.special_class_name,
            InlineBooleanFieldsAllowOnlyOneCheckedMixin.field_name_prefix + "is_best_seller",
            ]


    class CategoryAdmin(admin.ModelAdmin):
        inlines = [
            BookInline,
        ]

    admin.site.register(Category, CategoryAdmin)
    ```



## widget.AceWidget Usage

- `django_static_jquery3` and `django_static_ace_builds` required in INSTALLED_APPS.
- Create a model_form, and set the admin's form to the model_form.
- Set the field to use AceWidget in the model_form.
- Example:
```
class BookModelForm(forms.ModelForm):
    class Meta:
        model = Book
        fields = "__all__"
        widgets = {
            "description": AceWidget(ace_options={
                "mode": "ace/mode/yaml",
                "theme": "ace/theme/twilight",
            }),
        }

class BookAdmin(admin.ModelAdmin):
    form = BookModelForm
    list_display = ["title", "published"]

```

## Releases


| Release | Time | Changes                                                     | Notice |
| ------ | ---------- | ---------------------------------------------------------------- | ---- |
| v0.1.0 | 2020/08/12 | 1. First release.<br />2. Add UuidFieldSearchableAdmin.<br />3. Add InlineBooleanFieldsAllowOnlyOneCheckedMixin. | |
| v0.1.1 | 2020/08/13 | 4. Fix jquery.js and jquery.init.js including orders, so that we don't need to change js plugin's source to use django.jQuery. | |
| v0.2.0 | 2020/08/25 | 5. Add widgets.AceWidget. | |
| v0.3.0 | 2020/09/01 | 6. Change the directory structure of static files.<br />7. Add models.SimpleTask. It's an abstract model.<br />8. jQuery and jQuery plugins are moved to django-static-jquery3>=5.0.0. | |
| v0.3.1 | 2020/09/01 | 9. Rename zh_hans to zh_Hans.<br />10. Depends on django-db-lock>=0.3.1.<br />11. Add django-static-xxx depends. | |
| v0.3.2 | 2020/09/08 | 12. Add SimpleTaskService.<br />13. Move service functions from model to service.<br />14. Upgrade django_db_lock depends. | |
| v0.4.0 | 2020/09/23 | 15. Add widgets.TitleToCodeWidget.<br />16. Add models.SimplePublishModel.<br />17. Add many admin mixins.<br />18. Add app_requires. | |
| v0.5.0 | 2020/10/01 | 19. Add admin.AddAdminViewHelper.<br />20. Add admin.ToggleFieldStateAdmin.<br />21. Add admin.SimplePublishModelAdmin.<br />22. Add admin.SetTopModelAdmin. | |
| v0.6.0 | 2020/10/13 | 23. Add admin.DjangoAdminGlobalMedia.<br />24. Add admin.DjangoWithExtraContextAdmin.<br />25. Add admin.DjangoDynamicMediaAdmin.<br />26. Add admin.HiddenFieldsAdmin.<br />27. Add admin.HideShowFieldsOnValueAdmin.<br />28. Add admin.DjangoObjectToolbarAdmin.<br />29. Add admin.DjangoSortableAdmin.<br />30. Add depends. | |
| v0.6.1 | 2020/10/21 | 31. Upgrade django-db-lock, fix missing requests in setup problem. | |
| v0.6.2 | 2020/10/24 | 32. Fix DjangoWithExtraContextAdmin problem. | |
| v0.7.0 | 2020/10/27 | 33. Remove abstract models, so that django_fastadmin can forcus on admin extensions.<br />34. SimpleTask moved to django_simpletask.<br />35. SimplePublishModel and SimplePublishModelAdmin moved to django_simple_publish_model. | |
| v0.7.1 | 2020/11/08 | 36. Fix missing django-static-ace-builds problem. | |
| v0.7.2 | 2021/04/13 | 37. Fix InlineModelAdmin.has_add_permission(...) has obj paramter in Django 3.2 problem.<br />38. Test in Django 3.2. | |
