diff --git a/app/network/views.py b/app/network/views.py index 26e691e3201f129f7d547b57575f23ac08af586d..f917f1ffa5fc34ab4f404243235f63c8d01143b7 100644 --- a/app/network/views.py +++ b/app/network/views.py @@ -473,18 +473,24 @@ def create_scope(): @bp.route("/_retrieve_hosts") @login_required def retrieve_hosts(): - data = [ - ( - host.name, - str(host.device_type), - host.description, - interface.name, - interface.ip, - str(interface.network), - ) - for host in models.Host.query.all() - for interface in host.interfaces - ] + data = [] + for host in models.Host.query.all(): + if host.interfaces: + for interface in host.interfaces: + data.append( + ( + host.name, + str(host.device_type), + host.description, + interface.name, + interface.ip, + str(interface.network), + ) + ) + else: + data.append( + (host.name, str(host.device_type), host.description, "", "", "") + ) return jsonify(data=data)