Implementation of diff and patch from scratch in django