django-fsm transition integration to django admin.
Project description
django-fsm-admin2
Django-fsm transition integration to django admin.
Passing arguments to transition is supported (unlike django-fsm-admin package).
Installation
pip install django-fsm-admin2
Add fsm_admin to your settings.INSTALLED_APPS
INSTALLED_APPS = [
...
'fsm_admin2',
...
]
Usage
Add FSMTransitionMixin to your admin class
# admin.py
from django.contrib import admin
from fsm_admin2.admin import FSMTransitionMixin
class MyModelAdmin(FSMTransitionMixin, admin.ModelAdmin):
fsm_fields = ['status',] # list your fsm fields
# you can override templates for transition arguments form view and transition buttons row
fsm_transition_form_template = 'fsm_admin2/fsm_transition_form.html' # default value
fsm_transition_buttons_template = 'fsm_admin2/fsm_transition_buttons.html' # default value
...
This will add current field value as readonly field and buttons row to perform transitions. Only allowed transitions are displayed.
Customize transition display.
@transition(field=status, source='disabled', target='enabled',
custom={'short_description': 'Activate!!!'})
def activate(self):
...
Add form to provide transition arguments. Form fields names should match transition function arguments.
class DeactivateForm(forms.Form):
text = forms.Charfield()
@transition(field=status, source='enabled', target='disabled',
custom={'short_description': 'Deactivate', 'form': DeactivateForm})
def deactivate(self, text):
...
Form class can also be set as import string: {'form': 'my_app.forms.DeactivateForm'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_fsm_admin2-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01ad05c8a115783aab8c6a196adfde9ab58f513b00c62d180fcee57a8e9adaf3 |
|
MD5 | d6778fd6dceee590326d882287f8e0ae |
|
BLAKE2b-256 | f36d63783506185f2f85c39235e35355d863626b80ec60e932120f72044e501a |