Skip to content

Commit 212ee65

Browse files
committed
Fixed #2101 -- Renamed maxlength argument to max_length for oldforms FormFields and db model Fields. This is fully backwards compatible at the moment since the legacy maxlength argument is still supported. Using maxlength will, however, issue a PendingDeprecationWarning when used.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5803 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 973f44a commit 212ee65

File tree

88 files changed

+647
-407
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+647
-407
lines changed

django/contrib/admin/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class LogEntry(models.Model):
1818
user = models.ForeignKey(User)
1919
content_type = models.ForeignKey(ContentType, blank=True, null=True)
2020
object_id = models.TextField(_('object id'), blank=True, null=True)
21-
object_repr = models.CharField(_('object repr'), maxlength=200)
21+
object_repr = models.CharField(_('object repr'), max_length=200)
2222
action_flag = models.PositiveSmallIntegerField(_('action flag'))
2323
change_message = models.TextField(_('change message'), blank=True)
2424
objects = LogEntryManager()

django/contrib/admin/templatetags/admin_modify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def auto_populated_field_script(auto_pop_fields, change = False):
192192
t.append(u'document.getElementById("id_%s").onkeyup = function() {' \
193193
' var e = document.getElementById("id_%s");' \
194194
' if(!e._changed) { e.value = URLify(%s, %s);} }; ' % (
195-
f, field.name, add_values, field.maxlength))
195+
f, field.name, add_values, field.max_length))
196196
return u''.join(t)
197197
auto_populated_field_script = register.simple_tag(auto_populated_field_script)
198198

django/contrib/admin/views/doc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def get_return_data_type(func_name):
291291
DATA_TYPE_MAPPING = {
292292
'AutoField' : _('Integer'),
293293
'BooleanField' : _('Boolean (Either True or False)'),
294-
'CharField' : _('String (up to %(maxlength)s)'),
294+
'CharField' : _('String (up to %(max_length)s)'),
295295
'CommaSeparatedIntegerField': _('Comma-separated integers'),
296296
'DateField' : _('Date (without time)'),
297297
'DateTimeField' : _('Date (with time)'),
@@ -310,7 +310,7 @@ def get_return_data_type(func_name):
310310
'PhoneNumberField' : _('Phone number'),
311311
'PositiveIntegerField' : _('Integer'),
312312
'PositiveSmallIntegerField' : _('Integer'),
313-
'SlugField' : _('String (up to %(maxlength)s)'),
313+
'SlugField' : _('String (up to %(max_length)s)'),
314314
'SmallIntegerField' : _('Integer'),
315315
'TextField' : _('Text'),
316316
'TimeField' : _('Time'),

django/contrib/auth/forms.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class UserCreationForm(oldforms.Manipulator):
1010
"A form that creates a user, with no privileges, from the given username and password."
1111
def __init__(self):
1212
self.fields = (
13-
oldforms.TextField(field_name='username', length=30, maxlength=30, is_required=True,
13+
oldforms.TextField(field_name='username', length=30, max_length=30, is_required=True,
1414
validator_list=[validators.isAlphaNumeric, self.isValidUsername]),
15-
oldforms.PasswordField(field_name='password1', length=30, maxlength=60, is_required=True),
16-
oldforms.PasswordField(field_name='password2', length=30, maxlength=60, is_required=True,
15+
oldforms.PasswordField(field_name='password1', length=30, max_length=60, is_required=True),
16+
oldforms.PasswordField(field_name='password2', length=30, max_length=60, is_required=True,
1717
validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]),
1818
)
1919

@@ -42,9 +42,9 @@ def __init__(self, request=None):
4242
"""
4343
self.request = request
4444
self.fields = [
45-
oldforms.TextField(field_name="username", length=15, maxlength=30, is_required=True,
45+
oldforms.TextField(field_name="username", length=15, max_length=30, is_required=True,
4646
validator_list=[self.isValidUser, self.hasCookiesEnabled]),
47-
oldforms.PasswordField(field_name="password", length=15, maxlength=30, is_required=True),
47+
oldforms.PasswordField(field_name="password", length=15, max_length=30, is_required=True),
4848
]
4949
self.user_cache = None
5050

@@ -111,11 +111,11 @@ class PasswordChangeForm(oldforms.Manipulator):
111111
def __init__(self, user):
112112
self.user = user
113113
self.fields = (
114-
oldforms.PasswordField(field_name="old_password", length=30, maxlength=30, is_required=True,
114+
oldforms.PasswordField(field_name="old_password", length=30, max_length=30, is_required=True,
115115
validator_list=[self.isValidOldPassword]),
116-
oldforms.PasswordField(field_name="new_password1", length=30, maxlength=30, is_required=True,
116+
oldforms.PasswordField(field_name="new_password1", length=30, max_length=30, is_required=True,
117117
validator_list=[validators.AlwaysMatchesOtherField('new_password2', _("The two 'new password' fields didn't match."))]),
118-
oldforms.PasswordField(field_name="new_password2", length=30, maxlength=30, is_required=True),
118+
oldforms.PasswordField(field_name="new_password2", length=30, max_length=30, is_required=True),
119119
)
120120

121121
def isValidOldPassword(self, new_data, all_data):
@@ -133,8 +133,8 @@ class AdminPasswordChangeForm(oldforms.Manipulator):
133133
def __init__(self, user):
134134
self.user = user
135135
self.fields = (
136-
oldforms.PasswordField(field_name='password1', length=30, maxlength=60, is_required=True),
137-
oldforms.PasswordField(field_name='password2', length=30, maxlength=60, is_required=True,
136+
oldforms.PasswordField(field_name='password1', length=30, max_length=60, is_required=True),
137+
oldforms.PasswordField(field_name='password2', length=30, max_length=60, is_required=True,
138138
validator_list=[validators.AlwaysMatchesOtherField('password1', _("The two password fields didn't match."))]),
139139
)
140140

django/contrib/auth/models.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ class Permission(models.Model):
5050
5151
Three basic permissions -- add, change and delete -- are automatically created for each Django model.
5252
"""
53-
name = models.CharField(_('name'), maxlength=50)
53+
name = models.CharField(_('name'), max_length=50)
5454
content_type = models.ForeignKey(ContentType)
55-
codename = models.CharField(_('codename'), maxlength=100)
55+
codename = models.CharField(_('codename'), max_length=100)
5656

5757
class Meta:
5858
verbose_name = _('permission')
@@ -70,7 +70,7 @@ class Group(models.Model):
7070
7171
Beyond permissions, groups are a convenient way to categorize users to apply some label, or extended functionality, to them. For example, you could create a group 'Special users', and you could write code that would do special things to those users -- such as giving them access to a members-only portion of your site, or sending them members-only e-mail messages.
7272
"""
73-
name = models.CharField(_('name'), maxlength=80, unique=True)
73+
name = models.CharField(_('name'), max_length=80, unique=True)
7474
permissions = models.ManyToManyField(Permission, verbose_name=_('permissions'), blank=True, filter_interface=models.HORIZONTAL)
7575

7676
class Meta:
@@ -108,11 +108,11 @@ class User(models.Model):
108108
109109
Username and password are required. Other fields are optional.
110110
"""
111-
username = models.CharField(_('username'), maxlength=30, unique=True, validator_list=[validators.isAlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
112-
first_name = models.CharField(_('first name'), maxlength=30, blank=True)
113-
last_name = models.CharField(_('last name'), maxlength=30, blank=True)
111+
username = models.CharField(_('username'), max_length=30, unique=True, validator_list=[validators.isAlphaNumeric], help_text=_("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."))
112+
first_name = models.CharField(_('first name'), max_length=30, blank=True)
113+
last_name = models.CharField(_('last name'), max_length=30, blank=True)
114114
email = models.EmailField(_('e-mail address'), blank=True)
115-
password = models.CharField(_('password'), maxlength=128, help_text=_("Use '[algo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change password form</a>."))
115+
password = models.CharField(_('password'), max_length=128, help_text=_("Use '[algo]$[salt]$[hexdigest]' or use the <a href=\"password/\">change password form</a>."))
116116
is_staff = models.BooleanField(_('staff status'), default=False, help_text=_("Designates whether the user can log into this admin site."))
117117
is_active = models.BooleanField(_('active'), default=True, help_text=_("Designates whether this user can log into the Django admin. Unselect this instead of deleting accounts."))
118118
is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_("Designates that this user has all permissions without explicitly assigning them."))

django/contrib/comments/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class Comment(models.Model):
6565
user = models.ForeignKey(User, raw_id_admin=True)
6666
content_type = models.ForeignKey(ContentType)
6767
object_id = models.IntegerField(_('object ID'))
68-
headline = models.CharField(_('headline'), maxlength=255, blank=True)
69-
comment = models.TextField(_('comment'), maxlength=3000)
68+
headline = models.CharField(_('headline'), max_length=255, blank=True)
69+
comment = models.TextField(_('comment'), max_length=3000)
7070
rating1 = models.PositiveSmallIntegerField(_('rating #1'), blank=True, null=True)
7171
rating2 = models.PositiveSmallIntegerField(_('rating #2'), blank=True, null=True)
7272
rating3 = models.PositiveSmallIntegerField(_('rating #3'), blank=True, null=True)
@@ -164,8 +164,8 @@ class FreeComment(models.Model):
164164
# A FreeComment is a comment by a non-registered user.
165165
content_type = models.ForeignKey(ContentType)
166166
object_id = models.IntegerField(_('object ID'))
167-
comment = models.TextField(_('comment'), maxlength=3000)
168-
person_name = models.CharField(_("person's name"), maxlength=50)
167+
comment = models.TextField(_('comment'), max_length=3000)
168+
person_name = models.CharField(_("person's name"), max_length=50)
169169
submit_date = models.DateTimeField(_('date/time submitted'), auto_now_add=True)
170170
is_public = models.BooleanField(_('is public'))
171171
ip_address = models.IPAddressField(_('ip address'))

django/contrib/comments/views/comments.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_validator_list(rating_num):
2929
else:
3030
return []
3131
self.fields.extend([
32-
oldforms.LargeTextField(field_name="comment", maxlength=3000, is_required=True,
32+
oldforms.LargeTextField(field_name="comment", max_length=3000, is_required=True,
3333
validator_list=[self.hasNoProfanities]),
3434
oldforms.RadioSelectField(field_name="rating1", choices=choices,
3535
is_required=ratings_required and num_rating_choices > 0,
@@ -122,9 +122,9 @@ class PublicFreeCommentManipulator(oldforms.Manipulator):
122122
"Manipulator that handles public free (unregistered) comments"
123123
def __init__(self):
124124
self.fields = (
125-
oldforms.TextField(field_name="person_name", maxlength=50, is_required=True,
125+
oldforms.TextField(field_name="person_name", max_length=50, is_required=True,
126126
validator_list=[self.hasNoProfanities]),
127-
oldforms.LargeTextField(field_name="comment", maxlength=3000, is_required=True,
127+
oldforms.LargeTextField(field_name="comment", max_length=3000, is_required=True,
128128
validator_list=[self.hasNoProfanities]),
129129
)
130130

django/contrib/contenttypes/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def clear_cache(self):
3232
CONTENT_TYPE_CACHE = {}
3333

3434
class ContentType(models.Model):
35-
name = models.CharField(maxlength=100)
36-
app_label = models.CharField(maxlength=100)
37-
model = models.CharField(_('python model class name'), maxlength=100)
35+
name = models.CharField(max_length=100)
36+
app_label = models.CharField(max_length=100)
37+
model = models.CharField(_('python model class name'), max_length=100)
3838
objects = ContentTypeManager()
3939
class Meta:
4040
verbose_name = _('content type')

django/contrib/flatpages/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
from django.utils.translation import ugettext_lazy as _
55

66
class FlatPage(models.Model):
7-
url = models.CharField(_('URL'), maxlength=100, validator_list=[validators.isAlphaNumericURL], db_index=True,
7+
url = models.CharField(_('URL'), max_length=100, validator_list=[validators.isAlphaNumericURL], db_index=True,
88
help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes."))
9-
title = models.CharField(_('title'), maxlength=200)
9+
title = models.CharField(_('title'), max_length=200)
1010
content = models.TextField(_('content'))
1111
enable_comments = models.BooleanField(_('enable comments'))
12-
template_name = models.CharField(_('template name'), maxlength=70, blank=True,
12+
template_name = models.CharField(_('template name'), max_length=70, blank=True,
1313
help_text=_("Example: 'flatpages/contact_page.html'. If this isn't provided, the system will use 'flatpages/default.html'."))
1414
registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page."))
1515
sites = models.ManyToManyField(Site)

django/contrib/redirects/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
class Redirect(models.Model):
66
site = models.ForeignKey(Site, radio_admin=models.VERTICAL)
7-
old_path = models.CharField(_('redirect from'), maxlength=200, db_index=True,
7+
old_path = models.CharField(_('redirect from'), max_length=200, db_index=True,
88
help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'."))
9-
new_path = models.CharField(_('redirect to'), maxlength=200, blank=True,
9+
new_path = models.CharField(_('redirect to'), max_length=200, blank=True,
1010
help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'."))
1111

1212
class Meta:

0 commit comments

Comments
 (0)