Kaydet (Commit) 41b3a45f authored tarafından Gary Wilson Jr's avatar Gary Wilson Jr

Fixed #3557 -- Made `SlugField` inherit from `CharField` so that its…

Fixed #3557 -- Made `SlugField` inherit from `CharField` so that its `max_length` is properly set.  Removed `get_manipulator_field_objs` method since it's already provided by `CharField`.  Thanks, Russell Cloran.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6065 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst be39adeb
...@@ -79,6 +79,7 @@ answer newbie questions, and generally made Django that much better: ...@@ -79,6 +79,7 @@ answer newbie questions, and generally made Django that much better:
Bryan Chow <bryan at verdjn dot com> Bryan Chow <bryan at verdjn dot com>
Michal Chruszcz <troll@pld-linux.org> Michal Chruszcz <troll@pld-linux.org>
Ian Clelland <clelland@gmail.com> Ian Clelland <clelland@gmail.com>
Russell Cloran <russell@rucus.net>
colin@owlfish.com colin@owlfish.com
crankycoder@gmail.com crankycoder@gmail.com
Pete Crosier <pete.crosier@gmail.com> Pete Crosier <pete.crosier@gmail.com>
......
...@@ -906,17 +906,14 @@ class PositiveSmallIntegerField(IntegerField): ...@@ -906,17 +906,14 @@ class PositiveSmallIntegerField(IntegerField):
def get_manipulator_field_objs(self): def get_manipulator_field_objs(self):
return [oldforms.PositiveSmallIntegerField] return [oldforms.PositiveSmallIntegerField]
class SlugField(Field): class SlugField(CharField):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
kwargs['max_length'] = kwargs.get('max_length', 50) kwargs['max_length'] = kwargs.get('max_length', 50)
kwargs.setdefault('validator_list', []).append(validators.isSlug) kwargs.setdefault('validator_list', []).append(validators.isSlug)
# Set db_index=True unless it's been set manually. # Set db_index=True unless it's been set manually.
if 'db_index' not in kwargs: if 'db_index' not in kwargs:
kwargs['db_index'] = True kwargs['db_index'] = True
Field.__init__(self, *args, **kwargs) super(SlugField, self).__init__(*args, **kwargs)
def get_manipulator_field_objs(self):
return [oldforms.TextField]
class SmallIntegerField(IntegerField): class SmallIntegerField(IntegerField):
def get_manipulator_field_objs(self): def get_manipulator_field_objs(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment