Changing validation after changing the model

8 views
Skip to first unread message

BlogueroConnor

unread,
Apr 12, 2012, 12:21:14 PM4/12/12
to django...@googlegroups.com
Hello,

I have model and a DB with data. I have to change one field size (lets say, from 255 to 4000). The column is called "papers".
I made a South migration, by creating by hand a migration script, and it worked, since the size for this column was changed in the DB.
Now I have the column with the size I want, but, in the admin page, I still see the field size set to 255 because that is the size of the inputtext in the form for this field.
So I overrided the field to make more room for the new data size, by using:

formfield_for_dbfield(self, db_field, **kwargs):
....
        if db_field.name in ('papers',):
            return db_field.formfield(widget=forms.Textarea(
                attrs={'cols': 80, 'rows': 10},
            ))    

So now I have a bigger form.
But when I put more than 255 chars in it, I get a JS validation error telling me that "Ensure this value has at most 255 characters (it has 2332)."

So the question is how can I change the data size for the JS to take into account the new size?

Best,
SB
Reply all
Reply to author
Forward
0 new messages