                  return obj, created
          for k, v in six.iteritems(filtered_defaults):
              setattr(obj, k, v)
          try:
              sid = transaction.savepoint(using=self.db)
              obj.save(update_fields=filtered_defaults.keys(), using=self.db)
              transaction.savepoint_commit(sid, using=self.db)
              return obj, False
          except DatabaseError:
              transaction.savepoint_rollback(sid, using=self.db)
 
</s> remove         except DatabaseError:
 </s> add         except DatabaseError as e: </s> remove             obj = self.model(**params)
            sid = transaction.savepoint(using=self.db)
 </s> add  </s> remove             exc_info = sys.exc_info()
            try:
                return self.get(**lookup), False
            except self.model.DoesNotExist:
                # Re-raise the DatabaseError with its original traceback.
                six.reraise(*exc_info)
 </s> add             if isinstance(e, IntegrityError):
                try:
                    return self.get(**lookup), False
                except self.model.DoesNotExist:
                    pass
            six.reraise(*sys.exc_info())
                  return obj, created
          for k, v in six.iteritems(filtered_defaults):
              setattr(obj, k, v)
          try:

              obj.save(update_fields=filtered_defaults.keys(), using=self.db)
              transaction.savepoint_commit(sid, using=self.db)
              return obj, False
          except DatabaseError:
              transaction.savepoint_rollback(sid, using=self.db)
keep keep keep keep replace keep keep keep keep keep
 Fixed #20761 -- Fixed DatabaseError handling in get_or_create and update_or_create. 
django/db/models/query.py