I'm currently facing an issue while trying to define a transition identifier using the 'type' field of a ForeignKey model in Django. After carefully reading the documentation, I noticed that the examples provided primarily utilize the primary key for transition identifiers.
Here are some examples: Test examples
I'm wondering if anyone has experience or insights into how to specify a transition identifier using the 'type' field of my ForeignKey model (Stage).
Any guidance or examples demonstrating the correct approach in such scenarios would be greatly appreciated. Thank you!
class Stage(models.Model):
class Type(models.TextChoices):
SUBSCRIBED = (
"SUBSCRIBED",
_("Subscribed"),
)
SELECTED = (
"SELECTED",
_("Selected"),
)
APPROVED = (
"APPROVED",
_("Approved"),
)
name = models.CharField(max_length=255)
type = models.CharField(
max_length=255,
choices=Type.choices,
default=Type.CUSTOM,
)
class Recruitment(models.Model):
class Status(models.TextChoices):
ACTIVE = ("ACTIVE", _("Active"))
INACTIVE = ("INACTIVE", _("Inactive"))
stage = FSMKeyField(Stage, on_delete=models.RESTRICT, protected=True)
@transition(
field=stage,
source=[Stage.Type.SUBSCRIBED], #This not works
target=Stage.Type.SELECTED,
)
def select(self, description=None, by=None):
return "Candidate was selected!"
I want to discover a way to implement a feature.