django_xworkflows icon indicating copy to clipboard operation
django_xworkflows copied to clipboard

Add support for UUID pks

Open morlandi opened this issue 2 years ago • 0 comments

Hello @rbarrois , this is exactly the support I've always dreamed of for managing workflows in a Django project. Thank you.

I failed to use GenericTransitionLog() as my Models use UUID as pks.

At the moment I solved this at project level by introducing this variant, which seems to work:

class GenericTransitionLogWithUUID(xwf_models.GenericTransitionLog):
    """Abstract model for a minimal database logging setup.

    Specializes GenericTransitionLog to use a GenericForeignKey with UUID as pk.
    """
    content_id = models.UUIDField(_("Content id"), blank=True, null=True, db_index=True)

    class Meta:
        abstract = True

I think UUID should be considered first-citizens in the Django ecosystem sooner or later ... in case, I can add a specific unit test and prepare a PR. Let me know if you're interested; I do not mind a negative answer at all.

I would also add on_delete here and there to the ForeignKeys for better compatibility with recent versions of Django

morlandi avatar Jan 15 '23 07:01 morlandi