Fix django error and add a script for thread pruning