Ticket #7778: model_subclass_deletion.diff

File model_subclass_deletion.diff, 782 bytes (added by anonymous, 16 years ago)
  • django/db/models/query.py

     
    834834        update_query = sql.UpdateQuery(cls, connection)
    835835        for field in cls._meta.fields:
    836836            if field.rel and field.null and field.rel.to in seen_objs:
    837                 update_query.clear_related(field, pk_list)
     837                # Only clear a related field if the field's column really exists in the related class.
     838                if filter(lambda r_field:r_field.column == field.column, field.rel.to._meta.fields):
     839                    update_query.clear_related(field, pk_list)
    838840
    839841    # Now delete the actual data.
    840842    for cls in ordered_classes:
Back to Top