Ticket #13987: 13987_primary_key_fix_2.diff

File 13987_primary_key_fix_2.diff, 661 bytes (added by Aram Dulyan, 14 years ago)

2nd possible fix: fetching the field for current model when "_preparing" it.

  • django/db/models/options.py

     
    113113                # Promote the first parent link in lieu of adding yet another
    114114                # field.
    115115                field = self.parents.value_for_index(0)
     116                already_created = [fld for fld in self.local_fields if fld.name == field.name]
     117                if already_created:
     118                    field = already_created[0]
    116119                field.primary_key = True
    117120                self.setup_pk(field)
    118121            else:
Back to Top