gregmuellegger / django-autofixture

Can create auto-generated test data.
BSD 3-Clause "New" or "Revised" License
462 stars 118 forks source link

uuid field support #79

Closed jungornti closed 8 years ago

jungornti commented 8 years ago

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
gregmuellegger commented 8 years ago

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

jungornti commented 8 years ago

Created a pull request.