      all_models = []
      for app in models.get_apps():
          for model in models.get_models(app):
              all_models.append(model)
      if backend.uses_case_insensitive_names:
          converter = lambda x: x.upper()
      else:
          converter = lambda x: x
      return set([m for m in all_models if converter(m._meta.db_table) in map(converter, table_list)])
  
 
</s> remove     from django.db import backend, models
 </s> add     from django.db import connection, models </s> remove     if backend.uses_case_insensitive_names:
 </s> add     if connection.features.uses_case_insensitive_names: </s> remove         if backend.uses_case_insensitive_names:
 </s> add         if connection.features.uses_case_insensitive_names: </s> remove     if backend.supports_constraints:
 </s> add     if connection.features.supports_constraints: </s> remove             if backend.supports_constraints and model in references_to_delete:
 </s> add             if connection.features.supports_constraints and model in references_to_delete:
    if connection.features.uses_case_insensitive_names:
      all_models = []
      for app in models.get_apps():
          for model in models.get_models(app):
              all_models.append(model)
    if connection.features.uses_case_insensitive_names:
          converter = lambda x: x.upper()
      else:
          converter = lambda x: x
      return set([m for m in all_models if converter(m._meta.db_table) in map(converter, table_list)])
  
keep keep keep keep replace keep keep keep keep keep
 Implemented BaseDatabaseFeatures and changed all code to access it -- connection.features.foo instead of backend.foo

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5974 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/core/management/sql.py