Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplified metasystem get_db_prep_save() hook so that it doesn't take…

… an 'add' parameter -- it wasn't being used, anyway.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@454 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 258e6bc33034b755a6c94cfa22b6ee44b1494501 1 parent 0d060ba
Adrian Holovaty adrianholovaty authored
Showing with 9 additions and 9 deletions.
  1. +2 −2 django/core/meta/__init__.py
  2. +7 −7 django/core/meta/fields.py
4 django/core/meta/__init__.py
View
@@ -720,7 +720,7 @@ def method_save(opts, self):
add = not bool(getattr(self, opts.pk.name))
for f in non_pks:
f.pre_save(self, getattr(self, f.name), add)
- db_values = [f.get_db_prep_save(getattr(self, f.name), add) for f in non_pks]
+ db_values = [f.get_db_prep_save(getattr(self, f.name)) for f in non_pks]
# OneToOne objects are a special case because there's no AutoField, and the
# primary key field is set manually.
if isinstance(opts.pk.rel, OneToOne):
@@ -732,7 +732,7 @@ def method_save(opts, self):
placeholders = ['%s'] * len(field_names)
cursor.execute("INSERT INTO %s (%s) VALUES (%s)" % \
(opts.db_table, ','.join(field_names), ','.join(placeholders)),
- [f.get_db_prep_save(getattr(self, f.name), add=True) for f in opts.fields])
+ [f.get_db_prep_save(getattr(self, f.name)) for f in opts.fields])
else:
if not add:
cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \
14 django/core/meta/fields.py
View
@@ -89,7 +89,7 @@ def pre_save(self, obj, value, add):
"""
pass
- def get_db_prep_save(self, value, add):
+ def get_db_prep_save(self, value):
"Returns field's value prepared for saving into a database."
return value
@@ -284,21 +284,21 @@ def pre_save(self, obj, value, add):
if self.auto_now or (self.auto_now_add and add):
setattr(obj, self.name, datetime.datetime.now())
- def get_db_prep_save(self, value, add):
+ def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
if value is not None:
value = value.strftime('%Y-%m-%d')
- return Field.get_db_prep_save(self, value, add)
+ return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):
return [formfields.DateField]
class DateTimeField(DateField):
- def get_db_prep_save(self, value, add):
+ def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
if value is not None:
value = value.strftime('%Y-%m-%d %H:%M:%S')
- return Field.get_db_prep_save(self, value, add)
+ return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):
return [formfields.DateField, formfields.TimeField]
@@ -487,11 +487,11 @@ def pre_save(self, obj, value, add):
if self.auto_now or (self.auto_now_add and add):
setattr(obj, self.name, datetime.datetime.now().time())
- def get_db_prep_save(self, value, add):
+ def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
if value is not None:
value = value.strftime('%H:%M:%S')
- return Field.get_db_prep_save(self, value, add)
+ return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):
return [formfields.TimeField]
Please sign in to comment.
Something went wrong with that request. Please try again.