State translation in the admin
khlumzeemee opened this issue · comments
Hi,
I defined the states as a choice list to be able to translate the labels.
However this does not reflect in the admin panel, the state is still displayed as "new" (the key) where I was expecting "New" (the value)
Am I missing something?
#States are listed as choices to be translatable
NEW = 'new'
ACCEPTED = 'accepted'
AWAITING_REVIEW = 'awaiting_review'
REVIEWED = 'reviewed'
COMPLETED = 'completed'
CANCELLED = 'cancelled'
REJECTED = 'rejected'
STATES = (
(NEW, _('New')),
(ACCEPTED, _('Accepted')),
(AWAITING_REVIEW, _('Awaiting Review')),
(REVIEWED, _('Reviewed')),
(COMPLETED, _('Completed')),
(CANCELLED, _('Cancelled')),
(REJECTED, _('Rejected')),
)
state = FSMField(_('state'), default=NEW, protected=True)
The button's name defaults to the function name which can be overridden by custom configuration of the transition (logic is here:
)For example:
@transition(
field=revision_state,
source=RevisionState.DRAFT,
target=RevisionState.COPY,
conditions=draft_to_copy_conditions,
permission='dossiers.revise_dossier',
custom={'button_name': _('Ready for Copy')})
def ready_for_copy(self):
pass
Hi,
so you are telling me that my choice list is useless :)
How about the state itself (displayed as a non editable FSMfield in my case)? The value displayed in the form is the key, not the value.
@khlumzeemee the FSMField is managed as part of the django-fsm project itself, so you'd have to bring that issue to them. This project is a small utility using django-fsm :)
Hi,
FYI the issue is solved in case you were wondering. using the choices
attributes, the label is now displayed correctly in the admin.
Happy you found a solution @khlumzeemee !