max_length vs. maxlength

5 views
Skip to first unread message

Brad Fults

unread,
Mar 20, 2007, 1:20:41 PM3/20/07
to Django developers
In the newforms module, certain Fields have max_length and min_length
attributes [1]. This seems strange because the models API uses
maxlength [2] (note the lack of underscore), as does HTML [3], seen
when creating Widgets in newforms.

Is there a specific reason that newforms' Fields are using an
inconsistent name? If not, I suggest that these all be normalized to
"maxlength" and "minlength".

Thanks.

[1] - http://code.djangoproject.com/browser/django/trunk/django/newforms/fields.py#L89
[2] - http://www.djangoproject.com/documentation/model_api/#charfield
[3] - http://www.w3.org/TR/html401/interact/forms.html#adef-maxlength

--
Brad Fults

James Bennett

unread,
Mar 20, 2007, 1:27:13 PM3/20/07
to django-d...@googlegroups.com
On 3/20/07, Brad Fults <bfu...@gmail.com> wrote:
> Is there a specific reason that newforms' Fields are using an
> inconsistent name? If not, I suggest that these all be normalized to
> "maxlength" and "minlength".

Actually, the plan over the next couple releases is to normalize to
"max_length" everywhere; we'll probably start out by supporting either
version on models, and then deprecate "maxlength" and remove it
eventually.

--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

SmileyChris

unread,
Mar 20, 2007, 3:12:47 PM3/20/07
to Django developers

On Mar 21, 5:27 am, "James Bennett" <ubernost...@gmail.com> wrote:
> On 3/20/07, Brad Fults <bfu...@gmail.com> wrote:
>
> > Is there a specific reason that newforms' Fields are using an
> > inconsistent name? If not, I suggest that these all be normalized to
> > "maxlength" and "minlength".
>
> Actually, the plan over the next couple releases is to normalize to
> "max_length" everywhere; we'll probably start out by supporting either
> version on models, and then deprecate "maxlength" and remove it
> eventually.

This even has a ticket which (although I think is pretty solid) could
probably do with some real-world testing!
http://code.djangoproject.com/ticket/2101

So if you want to help out with this normalization Brad (or anyone
else), patch your local copy with that and report back.

Adrian Holovaty

unread,
Mar 20, 2007, 3:14:21 PM3/20/07
to django-d...@googlegroups.com
On 3/20/07, Brad Fults <bfu...@gmail.com> wrote:
> In the newforms module, certain Fields have max_length and min_length
> attributes [1]. This seems strange because the models API uses
> maxlength [2] (note the lack of underscore), as does HTML [3], seen
> when creating Widgets in newforms.
>
> Is there a specific reason that newforms' Fields are using an
> inconsistent name? If not, I suggest that these all be normalized to
> "maxlength" and "minlength".

Hey Brad,

This thread will answer your question:

http://groups.google.com/group/django-users/browse_thread/thread/a4e09b7b027b56bb/9aaeda1ea5bc87eb

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

Brad Fults

unread,
Mar 20, 2007, 5:03:40 PM3/20/07
to Django developers
On Mar 20, 12:14 pm, "Adrian Holovaty" <holov...@gmail.com> wrote:
> Hey Brad,
>
> This thread will answer your question:
>
> http://groups.google.com/group/django-users/browse_thread/thread/a4e0...
>
> Adrian

OK, at least it's an intended change. :)

Though, now I'm concerned that max_length on the Field is different
from maxlength (the HTML attribute) on the Widget, which are
frequently specified *right next to* one another. This seems
undesirable.

Thoughts?

--
Brad Fults

SmileyChris

unread,
Mar 20, 2007, 9:18:14 PM3/20/07
to Django developers
On Mar 21, 9:03 am, "Brad Fults" <bfu...@gmail.com> wrote:
> Though, now I'm concerned that max_length on the Field is different
> from maxlength (the HTML attribute) on the Widget, which are
> frequently specified *right next to* one another. This seems
> undesirable.

It's not that "frequent" that you have to explicitly specify the
maxlength html attribute - CharField sets it for you automatically.

Reply all
Reply to author
Forward
0 new messages