I am using django_fsm to manage state in my model. My model looks like:
from django.db import models,
from django_fsm import FSMField, transition
class MyModel(models.Model):
STATES = (
('pending', _('Pending')),
('active', _('Active'))
)
state = FSMField(choices=STATES, default='pending', protected=True)
@transition(field=state, source='pending', target='active')
def change_state(self):
pass
Should I add self.save() to change_state? Will it be called?
If calling
change_state()succeeds without raising an exception, the state field will be changed, but not written to the database.So for making changes into database you need to call obj.save() explicitly