move app factory functions to django