diff options
| author | Jeremy Dunck <jdunck@gmail.com> | 2007-03-23 16:35:57 +0000 |
|---|---|---|
| committer | Jeremy Dunck <jdunck@gmail.com> | 2007-03-23 16:35:57 +0000 |
| commit | fa3ed6e1341f7c8b468e2267b3fafddeb58cdac2 (patch) | |
| tree | 6d8bf65854f8431355e2d91cbc61a37ab6f23d9a /django/db/models/fields | |
| parent | 8b279b63bef5c1348cc27c50633fc2d5ef09d7c1 (diff) | |
gis: Merged revisions 4669-4785 via svnmerge from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@4786 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/fields')
| -rw-r--r-- | django/db/models/fields/__init__.py | 12 | ||||
| -rw-r--r-- | django/db/models/fields/generic.py | 1 |
2 files changed, 11 insertions, 2 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index e8a2c231c5..3972de7d4a 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -67,7 +67,7 @@ class Field(object): def __init__(self, verbose_name=None, name=None, primary_key=False, maxlength=None, unique=False, blank=False, null=False, db_index=False, - core=False, rel=None, default=NOT_PROVIDED, editable=True, + core=False, rel=None, default=NOT_PROVIDED, editable=True, serialize=True, prepopulate_from=None, unique_for_date=None, unique_for_month=None, unique_for_year=None, validator_list=None, choices=None, radio_admin=None, help_text='', db_column=None): @@ -78,6 +78,7 @@ class Field(object): self.blank, self.null = blank, null self.core, self.rel, self.default = core, rel, default self.editable = editable + self.serialize = serialize self.validator_list = validator_list or [] self.prepopulate_from = prepopulate_from self.unique_for_date, self.unique_for_month = unique_for_date, unique_for_month @@ -742,6 +743,13 @@ class NullBooleanField(Field): kwargs['null'] = True Field.__init__(self, *args, **kwargs) + def to_python(self, value): + if value in (None, True, False): return value + if value in ('None'): return None + if value in ('t', 'True', '1'): return True + if value in ('f', 'False', '0'): return False + raise validators.ValidationError, gettext("This value must be either None, True or False.") + def get_manipulator_field_objs(self): return [oldforms.NullBooleanField] @@ -819,7 +827,7 @@ class TimeField(Field): if value is not None: # MySQL will throw a warning if microseconds are given, because it # doesn't support microseconds. - if settings.DATABASE_ENGINE == 'mysql': + if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): value = value.replace(microsecond=0) value = str(value) return Field.get_db_prep_save(self, value) diff --git a/django/db/models/fields/generic.py b/django/db/models/fields/generic.py index 1ad8346e42..480ee689c9 100644 --- a/django/db/models/fields/generic.py +++ b/django/db/models/fields/generic.py @@ -94,6 +94,7 @@ class GenericRelation(RelatedField, Field): kwargs['blank'] = True kwargs['editable'] = False + kwargs['serialize'] = False Field.__init__(self, **kwargs) def get_manipulator_field_objs(self): |
