Templates¶
To use the templates you have to include 'django_transitions'
in
INSTALLED_APPS
in the projects settings.py
file:
INSTALLED_APPS = [
'django.contrib.admin',
...
'django_transitions', # this is only needed to find the templates.
]
The change_form
template adds workflow buttons to the admin change form,
and also provides the ‘save’ and ‘delete’ buttons.
This template can be applied to the django admin class:
change_form_template = 'transitions/change_form.html'
{% extends 'admin/change_form.html' %}
{% block submit_buttons_bottom %}
<!-- add the save and delete buttons -->
{{ block.super }}
<!-- Add buttons for available transitions -->
<div class="submit-row">
{% for event in original.get_available_events %}
<input type="submit" class="{{ event.cssclass }}" value="{{ event.label }}" name="_{{ event.transition.name }}">
{% endfor %}
</div>
{% endblock %}
The read_only_change_form
template adds workflow buttons to the admin change form,
and removes the ‘save’ and ‘delete’ buttons.
This template can be applied to the django admin class:
change_form_template = 'transitions/read_only_change_form.html'
{% extends 'admin/change_form.html' %}
{% block submit_buttons_bottom %}
<div class="submit-row">
{% for event in original.get_available_events %}
<input type="submit" class="{{ event.cssclass }}" value="{{ event.label }}" name="_{{ event.transition.name }}">
{% endfor %}
</div>
{% endblock %}