The global structure of this code is odd: since you have a function (export_to_git) that you want to use from a few places, put it someplace central, then import it where you need it.  Importing from a management command into a view is confusing.