berinhard/model_mommy

Can't override default generator using generator.add

robertfw opened this issue · 0 comments

The documentation states that you can override built in generators using generators.add. However, this doesn't seem to work. I was trying to override the CharField generator with one that generates shorter values (instead of using max_length all the time), and it wasn't registering.

Looking at mommy.Mommy.generate_value , the problem is that the generators.get case gets called after the self.type_mapping case, and type_mapping only accounts for overrides set using the MOMMY_CUSTOM_FIELDS_GEN setting.

This could be fixed by swapping the generators.get case with the self.type_mapping case, or by having init_type_mapping check for user customizations using generators.get