gregmuellegger/django-autofixture

uuid field support

Closed this issue · 2 comments

Hello, i noticed that autofixtures are missing UUIDField support, so the any fixture of the model with UUID field raises IntegrityError in case when that uuid field on the model is required.

For now i'am monkey patching the base class and everything works fine:

import uuid

from django.db.models import fields

from autofixture import AutoFixture, generators
from autofixture.base import AutoFixtureBase


class UUIDGenerator(generators.Generator):

    def generate(self):
        return uuid.uuid4()



def monkey_patch_autofixture():
    AutoFixtureBase.field_to_generator[fields.UUIDField] = UUIDGenerator

Cool, if you want you can provide a pull request for that with a proper UUIDGenerator.

Created a pull request.