model-bakers/model_bakery

Better exception message for non supported fields

berinhard opened this issue · 0 comments

Expected behavior

To add the field name to the exception that's raised when bakery can't handle a specific field type. Not having the field name in the exception forces the developer to inspect the model definition to figure out what's the name of the field they may want to add default values.

The ideal exception message could be something like:

TypeError: field field_name type <class 'markupfield.fields.MarkupField'> is not supported by baker.

Actual behavior

TypeError: <class 'markupfield.fields.MarkupField'> is not supported by baker.

Reproduction Steps

Install a thirdy party app which implements custom fields, define a model with an unsupported field type and try to call baker.make for that model.

Versions

Python: 3.9
Django: 3.2
Model Bakery: 1.3.2