Fixed #1296 -- Made SlugField maxlength configurable. Thanks, Matt
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2325 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
6b694097dc
commit
97eb38b21d
|
@ -260,7 +260,7 @@ DATA_TYPE_MAPPING = {
|
|||
'PhoneNumberField' : _('Phone number'),
|
||||
'PositiveIntegerField' : _('Integer'),
|
||||
'PositiveSmallIntegerField' : _('Integer'),
|
||||
'SlugField' : _('String (up to 50)'),
|
||||
'SlugField' : _('String (up to %(maxlength)s)'),
|
||||
'SmallIntegerField' : _('Integer'),
|
||||
'TextField' : _('Text'),
|
||||
'TimeField' : _('Time'),
|
||||
|
|
|
@ -153,7 +153,7 @@ DATA_TYPES = {
|
|||
'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',
|
||||
|
|
|
@ -174,7 +174,7 @@ DATA_TYPES = {
|
|||
'PhoneNumberField': 'varchar(20)',
|
||||
'PositiveIntegerField': 'integer UNSIGNED',
|
||||
'PositiveSmallIntegerField': 'smallint UNSIGNED',
|
||||
'SlugField': 'varchar(50)',
|
||||
'SlugField': 'varchar(%(maxlength)s)',
|
||||
'SmallIntegerField': 'smallint',
|
||||
'TextField': 'longtext',
|
||||
'TimeField': 'time',
|
||||
|
|
|
@ -176,7 +176,7 @@ DATA_TYPES = {
|
|||
'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',
|
||||
|
|
|
@ -177,7 +177,7 @@ DATA_TYPES = {
|
|||
'PhoneNumberField': 'varchar(20)',
|
||||
'PositiveIntegerField': 'integer unsigned',
|
||||
'PositiveSmallIntegerField': 'smallint unsigned',
|
||||
'SlugField': 'varchar(50)',
|
||||
'SlugField': 'varchar(%(maxlength)s)',
|
||||
'SmallIntegerField': 'smallint',
|
||||
'TextField': 'text',
|
||||
'TimeField': 'time',
|
||||
|
|
|
@ -604,7 +604,8 @@ class PositiveSmallIntegerField(IntegerField):
|
|||
|
||||
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'):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue