[Django]-%d format: a number is required, not NoneType for is_valid()

5👍

According to the Django documentation max_length is a required argument for CharField.

Hence, adding the max_length to the CharField should fix it.

I just had the same issue while adding a new Model and ModelForm, based on a preexisting Form, to an application in a Django 1.4 project. I had not used max_length in the Form (which worked without any issues) and since CharField is common to Form and Model, I tried using the field as it is. Kaboom!

Fortunately, I noticed the word ‘required’ in the documentation. The error message and traceback were not very helpful.

👤Rishab

Leave a comment