diff --git a/app/network/views.py b/app/network/views.py index e6cc053c2e607cd3c2eb523330b2f36776555c3e..4f639defe7df0a41ecd9020b861c2cf0ec34c7c5 100644 --- a/app/network/views.py +++ b/app/network/views.py @@ -175,6 +175,12 @@ def edit_interface(name): ips = [interface.ip] ips.extend([str(address) for address in interface.network.available_ips()]) form.ip.choices = utils.get_choices(ips) + # Passing tags as kwarg to the InterfaceForm doesn't work because + # obj takes precedence (but interface.tags contain Tag instances and not id) + # We need to update the default values. Calling process is required. + # See https://stackoverflow.com/questions/5519729/wtforms-how-to-select-options-in-selectmultiplefield + form.tags.default = [tag.id for tag in interface.tags] + form.tags.process(request.form) if form.validate_on_submit(): interface.name = form.interface_name.data interface.ip = form.ip.data