jamida
jamida

Reputation: 3029

Django model field max_length 3x varchar size?

I just realized that with a legacy table I'm using in a django app that a varchar(5) field (for example) is rendered in python as a models.CharField(max_length=15) field. This 3x size for the max length is very consistent across many other fields.

Why? or more importantly if I changed the django definition to be models.CharField(max_length=5) would I break anything?

Upvotes: 2

Views: 832

Answers (1)

lprsd
lprsd

Reputation: 87215

It is probably a manual error by someone who tried to write models.

No. It doesn't break anything if you change it to 5. Not only that, you should change it to 5, so your form validation itself will take care of that length where you have that field.

Upvotes: 2

Related Questions