(req, id)
return HttpResponse(json.dumps(response), content_type="application/json", status=200)
delete favorite and put favorite_info object in response.
    method is idempotent, if favorite does not exist, just return favorite_info.
delete favorite and put favorite_info object in response.
    method is idempotent, if favorite does not exist, just return favorite_info.
delete favorite and put favorite_info object in response . method is idempotent if favorite does not exist just return favorite_info .
def delete_favorite(req, id):
    """
    delete favorite and put favorite_info object in response.
    method is idempotent, if favorite does not exist, just return favorite_info.
    """
    try:
        favorite = models.Favorite.objects.get(user=req.user, pk=id)
        favorite.delete()
    except ObjectDoesNotExist:
        pass

    response = {"has_favorite": "false"}

    return HttpResponse(json.dumps(response), content_type="application/json", status=200)
def delete_favorite ( req , id ) : try : favorite = models . Favorite . objects . get ( user = req . user , pk = id ) favorite . delete ( ) except ObjectDoesNotExist : pass response = { "has_favorite" : "false" } return HttpResponse ( json . dumps ( response ) , content_type = "application/json" , status = 200 )