How to stop auto generating text in ShortUUIDField field
I have a model where ShortUUIDField automatically generating ids I want to disable the auto generation
class Mymodel(models.Model):
pid=ShortUUIDField(length=10,max_length=100,prefix="prd",alphabet="abcdef")
sample_id = ShortUUIDField(length=10, max_length=100, prefix="var", alphabet="abcdef", null=True, blank=True,default=lambda: None)
I added default=lambda: None
in sample_id
field but it is still automatically generating the ids. I want the id default to be blank
Set default=None
directly without a lambda, and blank=True
so the field can be empty.
class Mymodel(models.Model):
pid = ShortUUIDField(length=10, max_length=100, prefix="prd", alphabet="abcdef")
sample_id = ShortUUIDField(length=10, max_length=100, prefix="var", alphabet="abcdef", null=True, blank=True)
def save(self, *args, **kwargs):
if self.sample_id is None:
self.sample_id = None # leave it as None
super().save(*args, **kwargs)