Improve valid() for django format, fixing issue #460