lazybird/django-solo

support django UUIDField

ahmadly opened this issue · 1 comments

hi, when I use UUID as ID in a model like this:

   id = models.UUIDField(
        primary_key=True,
        default=uuid.uuid4,
        editable=False,
        db_index=True,
        unique=True,
        verbose_name=_('ID'),
        help_text=_('UUID'),
    )

django admin raise this error:

django.core.exceptions.ValidationError: ["'1' is not a valid UUID."]

because in solo.models.SingletonModel line 12 we have:

DEFAULT_SINGLETON_INSTANCE_ID = 1

class SingletonModel(models.Model):
    singleton_instance_id = DEFAULT_SINGLETON_INSTANCE_ID

fast solution:
create an abstract model and overwrite singleton_instance_id:

class UUIDSingletonModel(SingletonModel):
    singleton_instance_id = uuid.uuid4()

    class Meta:
        abstract = True

now, use UUIDSingletonModel instead of SingletonModel
its work for me
thanks for your good repo

ops, UUID loses after reload!
this is wrong