Don't catch AttributeError, explicitly check for model=None instead.