I'm trying to replace None
with 0
but I'm getting an error as none type object has no attribute 'replace'. This is what I have tried
views.py:
def Activity(UserID):
cursor = connection.cursor()
cursor.execute('EXEC [dbo].[sp_GetCurrentRunningActivityAudit] @UserId=%s',(UserID,))
result_set =cursor.fetchall()
data = []
for row in result_set:
TaskId = row[0]
data.append({
'TaskId':row[0],
'TaskName' : row[1],
'Source' : row[2],
'Requester' : row[3].replace('None', '0') if row[3] == None else row[3] ,
'type' : row[4],
'IsActive':GetCurrentSubTaskSTatus(TaskId),
})
print(data)
return Response(data[0], status=status.HTTP_200_OK)