fcurella / django-fakery

🏭 An easy-to-use implementation of Creation Methods for Django, backed by Faker.
http://django-fakery.readthedocs.org/en/stable/
MIT License
115 stars 6 forks source link

Custom mapping types support #62

Closed amchii closed 3 years ago

amchii commented 3 years ago

I have a custom field inherits from models.IntegerField:

class UnsignedIntegerField(models.IntegerField):
    def db_type(self, connection):
        return "integer UNSIGNED"

    def rel_db_type(self, connection):
        return "integer UNSIGNED"

but django-fakery treats it as models.IntegerField and makes a negative number, then error occured. So could you make an api to custom mappings types for custom fields😄?

fcurella commented 3 years ago

I agree there should be a way to add custom fields.

In the meantime, would subclassing models.PositiveIntegerField be an option?

amchii commented 3 years ago

In the meantime, would subclassing models.PositiveIntegerField be an option?

Yes, I've thought about it, but legacy code with specified database works fine and models.PositiveBigIntegerField new in Django 3.1.

fcurella commented 3 years ago

I've merged in support for custom fields in https://github.com/fcurella/django-fakery/pull/63 and released it as v3.1.0. Let me know if you get into any issues :)

amchii commented 3 years ago

OK, I will. Thanks!