[Answer]-I have a Django ModelForm with added fields and field limitations. Not all fields are showing


Use the correct field classes – in this case, forms.IntegerField rather than models.IntegerField. You’ll also need to change your arguments – for instance, override the widget for expiration_month to be a select widget, and for the ones where you’re trying to set the max_length you’ll need to pass the maxlength argument through to the widget instead, and define any validation you want to use.


If You use fields in Meta then You must list expliticly all fields that You want to use, even the ones You are adding to the form, but are not present in the model.

What do You mean by that You can’t change the fields in Meta? Can You change the __init__ function on the form? You can also subclass this form and override fields or __init__.

Leave a comment