Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #1296 -- Made SlugField maxlength configurable. Thanks, Matt

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2325 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 97eb38b21dfa2750f50b3a933adaf19661345dab 1 parent 6b69409
@adrianholovaty adrianholovaty authored
View
2  django/contrib/admin/views/doc.py
@@ -260,7 +260,7 @@ def get_return_data_type(func_name):
'PhoneNumberField' : _('Phone number'),
'PositiveIntegerField' : _('Integer'),
'PositiveSmallIntegerField' : _('Integer'),
- 'SlugField' : _('String (up to 50)'),
+ 'SlugField' : _('String (up to %(maxlength)s)'),
'SmallIntegerField' : _('Integer'),
'TextField' : _('Text'),
'TimeField' : _('Time'),
View
2  django/core/db/backends/ado_mssql.py
@@ -153,7 +153,7 @@ def get_relations(cursor, table_name):
'PhoneNumberField': 'varchar(20)',
'PositiveIntegerField': 'int CONSTRAINT [CK_int_pos_%(column)s] CHECK ([%(column)s] > 0)',
'PositiveSmallIntegerField': 'smallint CONSTRAINT [CK_smallint_pos_%(column)s] CHECK ([%(column)s] > 0)',
- 'SlugField': 'varchar(50)',
+ 'SlugField': 'varchar(%(maxlength)s)',
'SmallIntegerField': 'smallint',
'TextField': 'text',
'TimeField': 'time',
View
2  django/core/db/backends/mysql.py
@@ -174,7 +174,7 @@ def get_relations(cursor, table_name):
'PhoneNumberField': 'varchar(20)',
'PositiveIntegerField': 'integer UNSIGNED',
'PositiveSmallIntegerField': 'smallint UNSIGNED',
- 'SlugField': 'varchar(50)',
+ 'SlugField': 'varchar(%(maxlength)s)',
'SmallIntegerField': 'smallint',
'TextField': 'longtext',
'TimeField': 'time',
View
2  django/core/db/backends/postgresql.py
@@ -176,7 +176,7 @@ def get_relations(cursor, table_name):
'PhoneNumberField': 'varchar(20)',
'PositiveIntegerField': 'integer CHECK ("%(column)s" >= 0)',
'PositiveSmallIntegerField': 'smallint CHECK ("%(column)s" >= 0)',
- 'SlugField': 'varchar(50)',
+ 'SlugField': 'varchar(%(maxlength)s)',
'SmallIntegerField': 'smallint',
'TextField': 'text',
'TimeField': 'time',
View
2  django/core/db/backends/sqlite3.py
@@ -177,7 +177,7 @@ def get_relations(cursor, table_name):
'PhoneNumberField': 'varchar(20)',
'PositiveIntegerField': 'integer unsigned',
'PositiveSmallIntegerField': 'smallint unsigned',
- 'SlugField': 'varchar(50)',
+ 'SlugField': 'varchar(%(maxlength)s)',
'SmallIntegerField': 'smallint',
'TextField': 'text',
'TimeField': 'time',
View
3  django/core/meta/fields.py
@@ -604,7 +604,8 @@ def get_manipulator_field_objs(self):
class SlugField(Field):
def __init__(self, *args, **kwargs):
- kwargs['maxlength'] = 50
+ # Default to a maxlength of 50 but allow overrides.
+ kwargs['maxlength'] = kwargs.get('maxlength', 50)
kwargs.setdefault('validator_list', []).append(validators.isSlug)
# Set db_index=True unless it's been set manually.
if not kwargs.has_key('db_index'):
View
6 docs/model-api.txt
@@ -410,7 +410,11 @@ Here are all available field types:
containing only letters, numbers, underscores or hyphens. They're generally
used in URLs.
- Implies ``maxlength=50`` and ``db_index=True``.
+ In the Django development version, you can specify ``maxlength``. If
+ ``maxlength`` is not specified, Django will use a default length of 50. In
+ previous Django versions, there's no way to override the length of 50.
+
+ Implies ``db_index=True``.
Accepts an extra option, ``prepopulate_from``, which is a list of fields
from which to auto-populate the slug, via JavaScript, in the object's admin
Please sign in to comment.
Something went wrong with that request. Please try again.