Skip to content

Requiring a little help with export templates #6752

Answered by candlerb
DevilWAH asked this question in Q&A
Discussion options

You must be logged in to vote

Something like (untested):

{% if site.devices.filter(device_type__name="important device").count() > 0 -%}
TRUE
{% else -%}
FALSE
{% endif -%}

(There is no need to iterate over site.devices in a for loop; you just want the single answer)

Here's an example of a working filter I use in a custom link, for checking whether a device has exactly one management-only interface with exactly one IP address:

{% if obj.interfaces.filter(mgmt_only=True).count() == 1 and obj.interfaces.get(mgmt_only=True).ip_addresses.count() == 1 %}
...
{% endif %}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@DevilWAH
Comment options

@DevilWAH
Comment options

@DevilWAH
Comment options

Answer selected by ryanmerolle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants