django / django-localflavor

Country-specific Django helpers, formerly of contrib fame

Home Page:https://django-localflavor.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Field of CharField inheritance

claudep opened this issue · comments

Most of localflavor form fields inherit from CharField. However, some are directly inheriting from Field. Whenever you use those fields as the default form field for any model CharField, you'll get the __init__() got an unexpected keyword argument 'max_length' TypeError. I wonder if the fact some fields inheriting from Field only is a desing decision or simply an oversight.

@benkonrath, what do you think?

I suspect this is an oversight. I vaguely recall noticing this in the past but assumed that these fields were intentionally setup to inherit directly from Field. Since there's a specific issue with this setup, I think we should change all text based fields to inherit from CharField.

I think it's worthwhile to make a 3.1.1 release to address this. Do you see any compatibility issues with this change?

I can make a PR later this afternoon if you haven't already beat me to it.

Such changes could always give backwards incompatibilities, however, I think it's the right thing to do, and we can document the affected fields in the ChangeLog. I'll be pleased to review your patch :-)

There were more than I thought there would be and I have to do other stuff now. I'll finish the PR in the next couple of days and let you know when it's ready for review.

Sure, no rush! Just tell me if you'd like some help to cook the patches.

I can do it - it's giving me more motivation to finish my work on a Django wrapper to python-stdnum and possibly/eventually deprecate most of this stuff. :-)

Fixed by d7ba69b