No matter what method I try, I cannot seem to generate unique UUIDs. This seems like something that would be super basic so I'm really struggling to find the right method here.
import uuid
from django.db import models
from mixer.backend.django import mixer
class MyModel(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4)
objs = mixer.cycle(2).blend(MyModel) # raises unique constraint violation, please just use my default callable
objs = mixer.cycle(2).blend(MyModel, id=uuid.uuid4) # ok I would have at least expected this to work
mixer.register(MyModel, id=uuid.uuid) # nope!
objs = mixer.cycle(2).blend(MyModel)
objs =[mixer.blend(MyModel, id=uuid.uuid4) for _ in range(2)] # nope!
Am I missing something? I wish it would just use the callable default value defined on the model, or at least any of the other methods. The thing about UUIDs is that you don't have to fake them, just call the real function every time.
No matter what method I try, I cannot seem to generate unique UUIDs. This seems like something that would be super basic so I'm really struggling to find the right method here.
Am I missing something? I wish it would just use the callable default value defined on the model, or at least any of the other methods. The thing about UUIDs is that you don't have to fake them, just call the real function every time.