diff options
| author | Robin Munn <robin.munn@gmail.com> | 2006-12-08 15:10:09 +0000 |
|---|---|---|
| committer | Robin Munn <robin.munn@gmail.com> | 2006-12-08 15:10:09 +0000 |
| commit | 122426e7453ed638a0c5be7e8b925adcddea3889 (patch) | |
| tree | a095a661aca53e0ceee021d93a2a503783b71c14 /django/db | |
| parent | dadfca08c0db567ce33284aaa8eb388cf667a836 (diff) | |
sqlalchemy: Merged revisions 4054 to 4185 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/sqlalchemy@4186 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/__init__.py | 2 | ||||
| -rw-r--r-- | django/db/models/fields/__init__.py | 13 |
2 files changed, 3 insertions, 12 deletions
diff --git a/django/db/__init__.py b/django/db/__init__.py index e5b4d32e0b..4176b5aa79 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -18,7 +18,7 @@ except ImportError, e: available_backends = [f for f in os.listdir(backend_dir) if not f.startswith('_') and not f.startswith('.') and not f.endswith('.py') and not f.endswith('.pyc')] available_backends.sort() if settings.DATABASE_ENGINE not in available_backends: - raise ImproperlyConfigured, "%r isn't an available database backend. vailable options are: %s" % \ + raise ImproperlyConfigured, "%r isn't an available database backend. Available options are: %s" % \ (settings.DATABASE_ENGINE, ", ".join(map(repr, available_backends))) else: raise # If there's some other error, this must be an error in Django itself. diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index bc1eaf0a6a..8e8d68aad5 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -457,9 +457,7 @@ class DateField(Field): def get_db_prep_save(self, value): # Casts dates into string format for entry into database. - if isinstance(value, datetime.datetime): - value = value.date().strftime('%Y-%m-%d') - elif isinstance(value, datetime.date): + if value is not None: value = value.strftime('%Y-%m-%d') return Field.get_db_prep_save(self, value) @@ -489,19 +487,12 @@ class DateTimeField(DateField): def get_db_prep_save(self, value): # Casts dates into string format for entry into database. - if isinstance(value, datetime.datetime): + 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' and hasattr(value, 'microsecond'): value = value.replace(microsecond=0) value = str(value) - elif isinstance(value, datetime.date): - # MySQL will throw a warning if microseconds are given, because it - # doesn't support microseconds. - if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): - value = datetime.datetime(value.year, value.month, value.day, microsecond=0) - value = str(value) - return Field.get_db_prep_save(self, value) def get_db_prep_lookup(self, lookup_type, value): |
