Skip to main content

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


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-admin2-0.1.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

django_fsm_admin2-0.1.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file django-fsm-admin2-0.1.3.tar.gz.

File metadata

  • Download URL: django-fsm-admin2-0.1.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for django-fsm-admin2-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0f57b860c7ec48a92127ec574ebb469e0285b68fea3f283dea742b11845fde39
MD5 decc9b453e9ddcc39ab42159205a3dd2
BLAKE2b-256 fd6ca1186345bec396a66dc69a26d60c7249aa49ebb0aa3c733e1ee9fcccf146

See more details on using hashes here.

File details

Details for the file django_fsm_admin2-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: django_fsm_admin2-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for django_fsm_admin2-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 01ad05c8a115783aab8c6a196adfde9ab58f513b00c62d180fcee57a8e9adaf3
MD5 d6778fd6dceee590326d882287f8e0ae
BLAKE2b-256 f36d63783506185f2f85c39235e35355d863626b80ec60e932120f72044e501a

See more details on using hashes here.

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