Ticket #683: meta__init__.patch

File meta__init__.patch, 26.9 KB (added by jdunck@…, 19 years ago)

patch changing .column to .name when it seems to mean that.

  • django/core/meta/__init__.py

     
    153153        exceptions=None, permissions=None, get_latest_by=None,
    154154        order_with_respect_to=None, module_constants=None):
    155155
     156        #jgd
     157        #print "initing Options for " + verbose_name
     158       
    156159        # Save the original function args, for use by copy(). Note that we're
    157160        # NOT using copy.deepcopy(), because that would create a new copy of
    158161        # everything in memory, and it's better to conserve memory. Of course,
     
    209212            if f.primary_key:
    210213                self.pk = f
    211214                break
     215        #jgd
     216        #if self.pk:
     217        #  print "found pk " + self.pk.name
     218        #  if self.pk.db_column:
     219        #    print "col " + self.pk.db_column
     220        #else:
     221        #  print "didn't find pk"
    212222        # If a primary_key field hasn't been specified, add an
    213223        # auto-incrementing primary-key ID field automatically.
    214224        if self.pk is None:
     
    408418        # Gather all attributes that are Field instances.
    409419        fields = []
    410420        for obj_name, obj in attrs.items():
     421            print "field: " + obj_name
    411422            if isinstance(obj, Field):
    412423                obj.set_name(obj_name)
    413424                fields.append(obj)
     
    760771                            val = getattr(rel_obj, f.rel.field_name)
    761772                        except AttributeError:
    762773                            raise TypeError, "Invalid value: %r should be a %s instance, not a %s" % (f.name, f.rel.to, type(rel_obj))
    763                 setattr(self, f.column, val)
     774                #jgd
     775                #setattr(self, f.column, val)
     776                setattr(self, f.name, val)
    764777            else:
    765778                val = kwargs.pop(f.name, f.get_default())
    766779                setattr(self, f.name, val)
    767780        if kwargs:
    768781            raise TypeError, "'%s' is an invalid keyword argument for this function" % kwargs.keys()[0]
    769782    for i, arg in enumerate(args):
    770         setattr(self, opts.fields[i].column, arg)
     783        #jgd
     784        #setattr(self, opts.fields[i].column, arg)
     785        setattr(self, opts.fields[i].name, arg)
    771786
    772787def method_eq(opts, self, other):
    773     return isinstance(other, self.__class__) and getattr(self, opts.pk.column) == getattr(other, opts.pk.column)
     788    #jgd
     789    #return isinstance(other, self.__class__) and getattr(self, opts.pk.column) == getattr(other, opts.pk.column)
     790    return isinstance(other, self.__class__) and getattr(self, opts.pk.name) == getattr(other, opts.pk.name)
    774791
    775792def method_save(opts, self):
    776793    # Run any pre-save hooks.
     
    779796    non_pks = [f for f in opts.fields if not f.primary_key]
    780797    cursor = db.db.cursor()
    781798
     799    #jgd
     800    #print "saving"
    782801    # First, try an UPDATE. If that doesn't update anything, do an INSERT.
    783     pk_val = getattr(self, opts.pk.column)
     802    #jgd
     803    #pk_val = getattr(self, opts.pk.column)
     804    pk_val = getattr(self, opts.pk.name)
    784805    pk_set = bool(pk_val)
    785806    record_exists = True
    786807    if pk_set:
     808        #jgd
     809        #print "pk set"
    787810        # Determine whether a record with the primary key already exists.
    788811        cursor.execute("SELECT 1 FROM %s WHERE %s=%%s LIMIT 1" % (opts.db_table, opts.pk.column), [pk_val])
    789812        # If it does already exist, do an UPDATE.
    790813        if cursor.fetchone():
    791             db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.column), False)) for f in non_pks]
     814            #jgd
     815            #db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.column), False)) for f in non_pks]
     816            db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.name), False)) for f in non_pks]
    792817            cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % (opts.db_table,
    793818                ','.join(['%s=%%s' % f.column for f in non_pks]), opts.pk.column),
    794819                db_values + [pk_val])
    795820        else:
    796821            record_exists = False
    797822    if not pk_set or not record_exists:
     823        #jgd
     824        #print "pk not set"
     825        #jgd
    798826        field_names = [f.column for f in opts.fields if not isinstance(f, AutoField)]
     827        #>field_names = [f.name for f in opts.fields if not isinstance(f, AutoField)]
    799828        placeholders = ['%s'] * len(field_names)
    800         db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.column), True)) for f in opts.fields if not isinstance(f, AutoField)]
     829        #jgd
     830        #<db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.column), True)) for f in opts.fields if not isinstance(f, AutoField)]
     831        db_values = [f.get_db_prep_save(f.pre_save(getattr(self, f.name), True)) for f in opts.fields if not isinstance(f, AutoField)]
    801832        if opts.order_with_respect_to:
    802833            field_names.append('_order')
    803834            # TODO: This assumes the database supports subqueries.
    804835            placeholders.append('(SELECT COUNT(*) FROM %s WHERE %s = %%s)' % \
    805836                (opts.db_table, opts.order_with_respect_to.column))
    806             db_values.append(getattr(self, opts.order_with_respect_to.column))
     837            #jgd
     838            #db_values.append(getattr(self, opts.order_with_respect_to.column))
     839            db_values.append(getattr(self, opts.order_with_respect_to.name))
    807840        cursor.execute("INSERT INTO %s (%s) VALUES (%s)" % (opts.db_table,
    808841            ','.join(field_names), ','.join(placeholders)), db_values)
    809842        if opts.has_auto_field:
    810             setattr(self, opts.pk.column, db.get_last_insert_id(cursor, opts.db_table, opts.pk.column))
     843            #jgd
     844            #setattr(self, opts.pk.column, db.get_last_insert_id(cursor, opts.db_table, opts.pk.column))
     845            setattr(self, opts.pk.name, db.get_last_insert_id(cursor, opts.db_table, opts.pk.column))
    811846    db.db.commit()
    812847    # Run any post-save hooks.
    813848    if hasattr(self, '_post_save'):
    814849        self._post_save()
    815850
    816851def method_delete(opts, self):
    817     assert getattr(self, opts.pk.column) is not None, "%r can't be deleted because it doesn't have an ID."
     852    #jgd
     853    #assert getattr(self, opts.pk.column) is not None, "%r can't be deleted because it doesn't have an ID."
     854    assert getattr(self, opts.pk.name) is not None, "%r can't be deleted because it doesn't have an ID."
    818855    # Run any pre-delete hooks.
    819856    if hasattr(self, '_pre_delete'):
    820857        self._pre_delete()
     
    832869            for sub_obj in getattr(self, 'get_%s_list' % rel_opts_name)():
    833870                sub_obj.delete()
    834871    for rel_opts, rel_field in opts.get_all_related_many_to_many_objects():
     872        #jgd
     873        #cursor.execute("DELETE FROM %s WHERE %s_id=%%s" % (rel_field.get_m2m_db_table(rel_opts),
     874        #    self._meta.object_name.lower()), [getattr(self, opts.pk.column)])
    835875        cursor.execute("DELETE FROM %s WHERE %s_id=%%s" % (rel_field.get_m2m_db_table(rel_opts),
    836             self._meta.object_name.lower()), [getattr(self, opts.pk.column)])
     876            self._meta.object_name.lower()), [getattr(self, opts.pk.name)])
     877       
    837878    for f in opts.many_to_many:
     879        #jgd
     880        #cursor.execute("DELETE FROM %s WHERE %s_id=%%s" % (f.get_m2m_db_table(opts), self._meta.object_name.lower()),
     881        #    [getattr(self, opts.pk.column)])
    838882        cursor.execute("DELETE FROM %s WHERE %s_id=%%s" % (f.get_m2m_db_table(opts), self._meta.object_name.lower()),
    839             [getattr(self, opts.pk.column)])
    840     cursor.execute("DELETE FROM %s WHERE %s=%%s" % (opts.db_table, opts.pk.column), [getattr(self, opts.pk.column)])
     883            [getattr(self, opts.pk.name)])
     884       
     885    #jgd
     886    #cursor.execute("DELETE FROM %s WHERE %s=%%s" % (opts.db_table, opts.pk.column), [getattr(self, opts.pk.column)])
     887    cursor.execute("DELETE FROM %s WHERE %s=%%s" % (opts.db_table, opts.pk.column), [getattr(self, opts.pk.name)])
    841888    db.db.commit()
    842     setattr(self, opts.pk.column, None)
     889    #jgd
     890    #setattr(self, opts.pk.column, None)
     891    setattr(self, opts.pk.name, None)
    843892    for f in opts.fields:
    844         if isinstance(f, FileField) and getattr(self, f.column):
     893        #jgd
     894        #if isinstance(f, FileField) and getattr(self, f.column):
     895        if isinstance(f, FileField) and getattr(self, f.name):
    845896            file_name = getattr(self, 'get_%s_filename' % f.name)()
    846897            # If the file exists and no other object of this type references it,
    847898            # delete it from the filesystem.
     
    856907        self._next_in_order_cache = opts.get_model_module().get_object(order_by=('_order',),
    857908            where=['_order > (SELECT _order FROM %s WHERE %s=%%s)' % (opts.db_table, opts.pk.column),
    858909                '%s=%%s' % order_field.column], limit=1,
    859             params=[getattr(self, opts.pk.column), getattr(self, order_field.column)])
     910            #jgd
     911            #params=[getattr(self, opts.pk.column), getattr(self, order_field.column)])
     912            params=[getattr(self, opts.pk.name), getattr(self, order_field.name)])
    860913    return self._next_in_order_cache
    861914
    862915def method_get_previous_in_order(opts, order_field, self):
     
    873926def method_get_many_to_one(field_with_rel, self):
    874927    cache_var = field_with_rel.get_cache_name()
    875928    if not hasattr(self, cache_var):
    876         val = getattr(self, field_with_rel.column)
     929        #jgd
     930        #val = getattr(self, field_with_rel.column)
     931        val = getattr(self, field_with_rel.name)
    877932        mod = field_with_rel.rel.to.get_model_module()
    878933        if val is None:
    879934            raise getattr(mod, '%sDoesNotExist' % field_with_rel.rel.to.object_name)
     
    893948            field_with_rel.get_m2m_db_table(self._meta), rel.pk.column,
    894949            rel.object_name.lower(), self._meta.object_name.lower(), rel.get_order_sql('a'))
    895950        cursor = db.db.cursor()
    896         cursor.execute(sql, [getattr(self, self._meta.pk.column)])
     951        #jgd
     952        #cursor.execute(sql, [getattr(self, self._meta.pk.column)])
     953        cursor.execute(sql, [getattr(self, self._meta.pk.name)])
    897954        setattr(self, cache_var, [getattr(mod, rel.object_name)(*row) for row in cursor.fetchall()])
    898955    return getattr(self, cache_var)
    899956
     
    914971    rel = rel_field.rel.to
    915972    m2m_table = rel_field.get_m2m_db_table(self._meta)
    916973    cursor = db.db.cursor()
    917     this_id = getattr(self, self._meta.pk.column)
     974    #jgd
     975    #this_id = getattr(self, self._meta.pk.column)
     976    this_id = getattr(self, self._meta.pk.name)
    918977    if ids_to_delete:
    919978        sql = "DELETE FROM %s WHERE %s_id = %%s AND %s_id IN (%s)" % (m2m_table, self._meta.object_name.lower(), rel.object_name.lower(), ','.join(map(str, ids_to_delete)))
    920979        cursor.execute(sql, [this_id])
     
    9541013# Handles related many-to-many object retrieval.
    9551014# Examples: Album.get_song(), Album.get_song_list(), Album.get_song_count()
    9561015def method_get_related_many_to_many(method_name, opts, rel_mod, rel_field, self, **kwargs):
    957     kwargs['%s__%s__exact' % (rel_field.name, opts.pk.name)] = getattr(self, opts.pk.column)
     1016    #jgd
     1017    #kwargs['%s__%s__exact' % (rel_field.name, opts.pk.name)] = getattr(self, opts.pk.column)
     1018    kwargs['%s__%s__exact' % (rel_field.name, opts.pk.name)] = getattr(self, opts.pk.name)
    9581019    return getattr(rel_mod, method_name)(**kwargs)
    9591020
    9601021# Handles setting many-to-many related objects.
     
    9631024    id_list = map(int, id_list) # normalize to integers
    9641025    rel = rel_field.rel.to
    9651026    m2m_table = rel_field.get_m2m_db_table(rel_opts)
    966     this_id = getattr(self, self._meta.pk.column)
     1027    #jgd
     1028    #this_id = getattr(self, self._meta.pk.column)
     1029    this_id = getattr(self, self._meta.pk.name)
    9671030    cursor = db.db.cursor()
    9681031    cursor.execute("DELETE FROM %s WHERE %s_id = %%s" % (m2m_table, rel.object_name.lower()), [this_id])
    9691032    sql = "INSERT INTO %s (%s_id, %s_id) VALUES (%%s, %%s)" % (m2m_table, rel.object_name.lower(), rel_opts.object_name.lower())
     
    10001063# CHOICE-RELATED METHODS ###################
    10011064
    10021065def method_get_display_value(field, self):
    1003     value = getattr(self, field.column)
     1066    #jgd
     1067    #value = getattr(self, field.column)
     1068    value = getattr(self, field.name)
    10041069    return dict(field.choices).get(value, value)
    10051070
    10061071# FILE-RELATED METHODS #####################
     
    11511216
    11521217    # 'fields' is a list of field names to fetch.
    11531218    try:
    1154         fields = [opts.get_field(f).column for f in kwargs.pop('fields')]
     1219        #jgd
     1220        #fields = [opts.get_field(f).column for f in kwargs.pop('fields')]
     1221        fields = [opts.get_field(f).name for f in kwargs.pop('fields')]
    11551222    except KeyError: # Default to all fields.
    1156         fields = [f.column for f in opts.fields]
     1223        #jgd
     1224        #fields = [f.column for f in opts.fields]
     1225        fields = [f.name for f in opts.fields]
    11571226
    11581227    cursor = db.db.cursor()
    11591228    _, sql, params = function_get_sql_clause(opts, **kwargs)
     
    12031272    # table_count is used to ensure table aliases are unique.
    12041273    tables, join_where, where, params = [], [], [], []
    12051274    for kwarg, kwarg_value in kwarg_items:
     1275        #jgd
     1276        #print "kw: " + kwarg, kwarg_value
    12061277        if kwarg in ('order_by', 'limit', 'offset', 'select_related', 'distinct', 'select', 'tables', 'where', 'params'):
    12071278            continue
    12081279        if kwarg_value is None:
     
    12181289        lookup_list = kwarg.split(LOOKUP_SEPARATOR)
    12191290        # pk="value" is shorthand for (primary key)__exact="value"
    12201291        if lookup_list[-1] == 'pk':
     1292            #jgd
     1293            #print "looking up pk"
    12211294            if opts.pk.rel:
     1295                #print "pk rel"
    12221296                lookup_list = lookup_list[:-1] + [opts.pk.name, opts.pk.rel.field_name, 'exact']
    12231297            else:
     1298                #print "pk no rel"
    12241299                lookup_list = lookup_list[:-1] + [opts.pk.name, 'exact']
    12251300        if len(lookup_list) == 1:
     1301            #jgd
     1302            #print "len(lookup_list) == 1"
    12261303            _throw_bad_kwarg_error(kwarg)
    12271304        lookup_type = lookup_list.pop()
    12281305        current_opts = opts # We'll be overwriting this, so keep a reference to the original opts.
    12291306        current_table_alias = current_opts.db_table
    12301307        param_required = False
    12311308        while lookup_list or param_required:
     1309            #jgd
     1310            #print "looking up " + str(lookup_list)
    12321311            table_count += 1
    12331312            try:
    12341313                # "current" is a piece of the lookup list. For example, in
     
    12401319                    # If we're here, lookup_list is empty but param_required
    12411320                    # is set to True, which means the kwarg was bad.
    12421321                    # Example: choices.get_list(poll__exact='foo')
     1322                    #jgd
     1323                    #print "bad lookup pop"
    12431324                    _throw_bad_kwarg_error(kwarg)
    12441325                # Try many-to-many relationships first...
    12451326                for f in current_opts.many_to_many:
     1327                    #jgd
     1328                    #print "trying many to many " + str(f.name)
    12461329                    if f.name == current:
     1330                        #jgd
     1331                        #print "found m-to-m rel"
    12471332                        rel_table_alias = 't%s' % table_count
    12481333                        table_count += 1
    12491334                        tables.append('%s %s' % (f.get_m2m_db_table(current_opts), rel_table_alias))
     
    12521337                        # Optimization: In the case of primary-key lookups, we
    12531338                        # don't have to do an extra join.
    12541339                        if lookup_list and lookup_list[0] == f.rel.to.pk.name and lookup_type == 'exact':
     1340                            #jgd
     1341                            #print "doing m-to-m pk lookup"
    12551342                            where.append(_get_where_clause(lookup_type, rel_table_alias+'.',
    12561343                                f.rel.to.object_name.lower()+'_id', kwarg_value))
    12571344                            params.extend(f.get_db_prep_lookup(lookup_type, kwarg_value))
    12581345                            lookup_list.pop()
    12591346                            param_required = False
    12601347                        else:
     1348                            #jgd
     1349                            #print "doing m-to-m regular lookup"
    12611350                            new_table_alias = 't%s' % table_count
    12621351                            tables.append('%s %s' % (f.rel.to.db_table, new_table_alias))
    12631352                            join_where.append('%s.%s_id = %s.%s' % (rel_table_alias, f.rel.to.object_name.lower(),
    12641353                                new_table_alias, f.rel.to.pk.column))
    12651354                            current_table_alias = new_table_alias
    12661355                            param_required = True
     1356                        #jgd
     1357                        #print "switching opts to be relative to m-to-m join target and jumping to next lookup"
    12671358                        current_opts = f.rel.to
    12681359                        raise StopIteration
    12691360                for f in current_opts.fields:
     1361                    #jgd
     1362                    #print "trying one to many " + str(f.name)
     1363
    12701364                    # Try many-to-one relationships...
    12711365                    if f.rel and f.name == current:
     1366                        #jgd
     1367                        #print "found 1-to-m rel "
    12721368                        # Optimization: In the case of primary-key lookups, we
    12731369                        # don't have to do an extra join.
    12741370                        if lookup_list and lookup_list[0] == f.rel.to.pk.name and lookup_type == 'exact':
     1371                            #jgd
     1372                            #print "pk look up"
    12751373                            where.append(_get_where_clause(lookup_type, current_table_alias+'.', f.column, kwarg_value))
    12761374                            params.extend(f.get_db_prep_lookup(lookup_type, kwarg_value))
    12771375                            lookup_list.pop()
     
    12801378                        # because we don't want to do a join. We just want to find out
    12811379                        # whether the foreign key field is NULL.
    12821380                        elif lookup_type == 'isnull' and not lookup_list:
     1381                            #jgd
     1382                            #print "isnull lookup"                       
    12831383                            where.append(_get_where_clause(lookup_type, current_table_alias+'.', f.column, kwarg_value))
    12841384                            params.extend(f.get_db_prep_lookup(lookup_type, kwarg_value))
    12851385                        else:
     1386                            #jgd
     1387                            #print "regular 1-to-m lookup"                       
    12861388                            new_table_alias = 't%s' % table_count
    12871389                            tables.append('%s %s' % (f.rel.to.db_table, new_table_alias))
    12881390                            join_where.append('%s.%s = %s.%s' % (current_table_alias, f.column, \
    12891391                                new_table_alias, f.rel.to.pk.column))
    12901392                            current_table_alias = new_table_alias
    12911393                            param_required = True
     1394                        #jgd
     1395                        #print "switching opts to be relative to 1-to-m join target and jumping to next lookup"
    12921396                        current_opts = f.rel.to
    12931397                        raise StopIteration
    12941398                    # Try direct field-name lookups...
    12951399                    if f.name == current:
     1400                        #jgd
     1401                        #print "found direct field name"
    12961402                        where.append(_get_where_clause(lookup_type, current_table_alias+'.', f.column, kwarg_value))
    12971403                        params.extend(f.get_db_prep_lookup(lookup_type, kwarg_value))
    12981404                        param_required = False
    12991405                        raise StopIteration
    13001406                # If we haven't hit StopIteration at this point, "current" must be
    13011407                # an invalid lookup, so raise an exception.
     1408                #jgd
     1409                #print "can't figure it out"
    13021410                _throw_bad_kwarg_error(kwarg)
    13031411            except StopIteration:
    13041412                continue
     
    13631471    kwargs['where'] = ["%s.%s IN (%s)" % (opts.db_table, opts.pk.column, ",".join(['%s'] * len(id_list)))]
    13641472    kwargs['params'] = id_list
    13651473    obj_list = function_get_list(opts, klass, **kwargs)
    1366     return dict([(getattr(o, opts.pk.column), o) for o in obj_list])
     1474    #jgd
     1475    #return dict([(getattr(o, opts.pk.column), o) for o in obj_list])
     1476    return dict([(getattr(o, opts.pk.name), o) for o in obj_list])
    13671477
    13681478def function_get_latest(opts, klass, does_not_exist_exception, **kwargs):
    13691479    kwargs['order_by'] = ('-' + opts.get_latest_by,)
     
    14331543                lookup_kwargs = opts.one_to_one_field.rel.limit_choices_to
    14341544                lookup_kwargs['%s__exact' % opts.one_to_one_field.rel.field_name] = obj_key
    14351545                _ = opts.one_to_one_field.rel.to.get_model_module().get_object(**lookup_kwargs)
    1436                 params = dict([(f.column, f.get_default()) for f in opts.fields])
    1437                 params[opts.pk.column] = obj_key
     1546
     1547                #jgd
     1548                #params = dict([(f.column, f.get_default()) for f in opts.fields])
     1549                #params[opts.pk.column] = obj_key
     1550                params = dict([(f.name, f.get_default()) for f in opts.fields])
     1551                params[opts.pk.name] = obj_key               
    14381552                self.original_object = opts.get_model_module().Klass(**params)
    14391553            else:
    14401554                raise
     
    14691583    for f in opts.fields:
    14701584        # Fields with auto_now_add are another special case; they should keep
    14711585        # their original value in the change stage.
     1586
     1587        #jgd
    14721588        if change and getattr(f, 'auto_now_add', False):
    1473             params[f.column] = getattr(self.original_object, f.name)
     1589            #params[f.column] = getattr(self.original_object, f.name)
     1590            params[f.name] = getattr(self.original_object, f.name)
    14741591        else:
    1475             params[f.column] = f.get_manipulator_new_data(new_data)
     1592            #params[f.column] = f.get_manipulator_new_data(new_data)
     1593            params[f.name] = f.get_manipulator_new_data(new_data)
    14761594
    14771595    if change:
    1478         params[opts.pk.column] = self.obj_key
     1596        #params[opts.pk.column] = self.obj_key
     1597        params[opts.pk.name] = self.obj_key
    14791598
    14801599    # First, save the basic object itself.
    14811600    new_object = klass(**params)
     
    14901609    if change:
    14911610        self.fields_added, self.fields_changed, self.fields_deleted = [], [], []
    14921611        for f in opts.fields:
    1493             if not f.primary_key and str(getattr(self.original_object, f.column)) != str(getattr(new_object, f.column)):
     1612            #jgd
     1613            #if not f.primary_key and str(getattr(self.original_object, f.column)) != str(getattr(new_object, f.column)):
     1614            if not f.primary_key and str(getattr(self.original_object, f.name)) != str(getattr(new_object, f.name)):
     1615                #jgd really want verbose_name here?
    14941616                self.fields_changed.append(f.verbose_name)
    14951617
    14961618    # Save many-to-many objects. Example: Poll.set_sites()
     
    15411663                # case, because they'll be dealt with later.
    15421664                if change and (isinstance(f, FileField) or not f.editable):
    15431665                    if rel_new_data.get(rel_opts.pk.name, False) and rel_new_data[rel_opts.pk.name][0]:
    1544                         params[f.column] = getattr(old_rel_obj, f.column)
     1666                        #jgd
     1667                        #params[f.column] = getattr(old_rel_obj, f.column)
     1668                        params[f.name] = getattr(old_rel_obj, f.name)
    15451669                    else:
    1546                         params[f.column] = f.get_default()
     1670                        #jgd
     1671                        #params[f.column] = f.get_default()
     1672                        params[f.name] = f.get_default()
    15471673                elif f == rel_field:
    1548                     params[f.column] = getattr(new_object, rel_field.rel.field_name)
     1674                    #jgd
     1675                    #params[f.column] = getattr(new_object, rel_field.rel.field_name)
     1676                    params[f.name] = getattr(new_object, rel_field.rel.field_name)
    15491677                elif add and isinstance(f, AutoField):
    1550                     params[f.column] = None
     1678                    #jgd
     1679                    #params[f.column] = None
     1680                    params[f.name] = None
    15511681                else:
    1552                     params[f.column] = f.get_manipulator_new_data(rel_new_data, rel=True)
     1682                    #jgd
     1683                    #params[f.column] = f.get_manipulator_new_data(rel_new_data, rel=True)
     1684                    params[f.name] = f.get_manipulator_new_data(rel_new_data, rel=True)
    15531685                # Related links are a special case, because we have to
    15541686                # manually set the "content_type_id" and "object_id" fields.
    15551687                if opts.has_related_links and rel_opts.module_name == 'relatedlinks':
     
    15751707                        self.fields_added.append('%s "%r"' % (rel_opts.verbose_name, new_rel_obj))
    15761708                    else:
    15771709                        for f in rel_opts.fields:
    1578                             if not f.primary_key and f != rel_field and str(getattr(old_rel_obj, f.column)) != str(getattr(new_rel_obj, f.column)):
     1710                            #jgd
     1711                            #if not f.primary_key and f != rel_field and str(getattr(old_rel_obj, f.column)) != str(getattr(new_rel_obj, f.column)):
     1712                            if not f.primary_key and f != rel_field and str(getattr(old_rel_obj, f.name)) != str(getattr(new_rel_obj, f.name)):
    15791713                                self.fields_changed.append('%s for %s "%r"' % (f.verbose_name, rel_opts.verbose_name, new_rel_obj))
    15801714
    15811715                # Save many-to-many objects.
     
    16061740    else:
    16071741        kwargs = {'%s__iexact' % field_name_list[0]: field_data}
    16081742    for f in field_list[1:]:
    1609         field_val = all_data.get(f.column, None)
     1743        #jgd
     1744        #field_val = all_data.get(f.column, None)
     1745        field_val = all_data.get(f.name, None)
    16101746        if field_val is None:
    16111747            # This will be caught by another validator, assuming the field
    16121748            # doesn't have blank=True.
     
    16201756        old_obj = mod.get_object(**kwargs)
    16211757    except ObjectDoesNotExist:
    16221758        return
    1623     if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.column) == getattr(old_obj, opts.pk.column):
     1759    #jgd
     1760    #if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.column) == getattr(old_obj, opts.pk.column):
     1761    if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.name) == getattr(old_obj, opts.pk.name):
    16241762        pass
    16251763    else:
    16261764        raise validators.ValidationError, "%s with this %s already exists for the given %s." % \
     
    16461784    except ObjectDoesNotExist:
    16471785        return
    16481786    else:
    1649         if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.column) == getattr(old_obj, opts.pk.column):
     1787        #jgd
     1788        #if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.column) == getattr(old_obj, opts.pk.column):
     1789        if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.name) == getattr(old_obj, opts.pk.name):
    16501790            pass
    16511791        else:
    16521792            format_string = (lookup_type == 'date') and '%B %d, %Y' or '%B %Y'
Back to Top