Skip to main content

Integrate django-fsm state transitions into Django Admin.

Project description

django-fsm-admin-lite

Generic badge

Integrate django-fsm state transitions into Django Admin.

Alternative of django-fsm-admin, with a lighter version of the frontend part.

Features:

  • display available transitions in model admin so that user can apply them
  • mark FSM protected fields as read only

Limitations:

  • transition methods parameters are not handled

Installation

pip install django-fsm-admin-lite

Or, for the latest git version

python -m pip install 'django-fsm-admin-lite @ git+https://github.com/etchegom/django-fsm-admin-lite.git'

Usage

Make you model admin class inherit from the mixin class FSMAdminMixin.

from django.contrib import admin
from fsm_admin_lite.mixins import FSMAdminMixin

@admin.register(MyModel)
class MyModelAdmin(FSMAdminMixin, admin.ModelAdmin):
    fsm_fields = [
        "state",
    ]

Configuration

Admin class attribute Option
fsm_fields List of FSM fields to handle
fsm_transition_success_msg Admin message for transition success
fsm_transition_error_msg Admin message for transition error
fsm_transition_not_allowed_msg Admin message for transition not allowed error
fsm_transition_not_valid_msg Admin message for transition not valid error
fsm_context_key Template context key for FSM transitions
fsm_post_param POST parameter name for FSM transitions

Run example

make example

Then go to http://127.0.0.1:8000/admin, login with admin/password and create a new blog post object.


TODO

  • improve the default template files
  • display all the transitions (not available transition should be represented as disabled buttons)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_fsm_admin_lite-0.1.0.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

django_fsm_admin_lite-0.1.0-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page