Factored out functions to django report utils