Check user.is_authenticated() instead (which will allow the import to be removed)