jazzband / django-fsm-log

Automatic logging for Django FSM
https://django-fsm-log.readthedocs.io/en/latest/
MIT License
241 stars 78 forks source link

Handle multiple state fields #74

Open blueyed opened 6 years ago

blueyed commented 6 years ago

Currently the field keyword argument in the signal handler is not being handled.

Therefore, if multiple state fields (e.g. "state" and "second_state") are being used those cannot be easily distinguished in the logs.

Do you think it makes sense to add "field_name" to StateLog, where kwargs['field'].name would be stored into?

This could also be used in __str__ then, but is typically redundant then (since often only a single state field is used probably).

jonasvp commented 6 years ago

This wouldn't be hard but does django-fsm actually send a field kwarg? It's not documented here: https://github.com/kmmbvnr/django-fsm#signals

Also, since transitions always refer to a specific field, you can just do getattr(Model, transition)._django_fsm.field to get to it later.