surely django has a util for this?