941 | | db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.attname), True)) for f in opts.fields if not isinstance(f, AutoField)] |
| 941 | db_values = [] |
| 942 | # Pre-save all values. We could do this as a one-liner, but then |
| 943 | # it'd be near-impossible to figure out which field was causing |
| 944 | # the problem. |
| 945 | for f in opts.fields: |
| 946 | if not isinstance(f, AutoField): |
| 947 | try: |
| 948 | val = getattr(self, f.attname) |
| 949 | f_presave = f.pre_save(val, True) |
| 950 | db_presave = f.get_db_prep_save(f_presave) |
| 951 | db_values.append(db_presave) |
| 952 | except Exception, ex: |
| 953 | # Append a message to the exception's arguments, |
| 954 | # and then re-raise it. Yes, Veronica, this works. |
| 955 | msg = "save() can't handle field %s" % f.attname |
| 956 | ex.args = tuple(list(ex.args)+[msg]) |
| 957 | raise |