nautobot.apps.templatetags
¶
Template tags for Nautobot.
nautobot.apps.templatetags.action_url(instance, action)
¶
URL to the
Helper to edit_button, delete_button and consolidated_detail_view_action_buttons tags,
but can be used separately if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
BaseModel
|
Model record. |
required |
action
|
str
|
Action (add/edit/delete) to link to. |
required |
nautobot.apps.templatetags.add_button(url, verbose_name=None, list_element=False)
¶
Display an Add Button/List Element on the page.
This allows an Add Button to either be displayed on a page or within a Button Group. Args: url (str): URL for the object's create page. verbose_name (str, optional): Append the verbose_name to the button text. list_element (bool, optional): Render as a
nautobot.apps.templatetags.add_html_id(element_str, id_str)
¶
Add an HTML id="..." attribute to the given HTML element string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element_str
|
str
|
String describing an HTML element. |
required |
id_str
|
str
|
String to add as the |
required |
Returns:
| Type | Description |
|---|---|
str
|
HTML string with added |
nautobot.apps.templatetags.as_range(n)
¶
Return a range of n items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
(int, str)
|
Number of element in the range |
required |
Returns:
| Type | Description |
|---|---|
Union[list, Range]
|
range function from o to the value provided. Returns an empty list if n is not valid. |
Example
{% for i in record.ancestors.count|as_range %}
nautobot.apps.templatetags.badge(value, show_empty=False)
¶
Display the specified number as a badge.
nautobot.apps.templatetags.bettertitle(value)
¶
Alternative to the builtin title(); capitalizes words without replacing letters that are already uppercase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
string to convert to Title Case |
required |
Returns:
| Type | Description |
|---|---|
str
|
string in Title format |
Example
bettertitle("IP address") "IP Address"
nautobot.apps.templatetags.computed_fields(context, obj, advanced_ui=None)
¶
Render all applicable links for the given object. This can also check whether the advanced_ui attribute is True or False for UI display purposes.
nautobot.apps.templatetags.consolidate_bulk_action_buttons(context)
¶
Generates a list of action buttons for bulk operations (edit, update group assignment, delete) based on the model capabilities and user permissions.
Context must include the following keys
request (HttpRequest): The HTTP request object. model (Model): The model class for the list view. user (User): The current user. bulk_edit_url (str): The URL for the bulk edit action. bulk_delete_url (str): The URL for the bulk delete action. permissions (dict): A dictionary of specific permissions for the view.
nautobot.apps.templatetags.consolidate_detail_view_action_buttons(context)
¶
Generates a list of action buttons for detail view operations (edit, clone, delete) based on the model capabilities and user permissions.
Context must include the following keys
request (HttpRequest): The HTTP request object. object (Model): The object in the detail view. user (User): The current user.
nautobot.apps.templatetags.custom_branding_or_static(branding_asset, static_asset)
¶
This tag attempts to return custom branding assets relative to the MEDIA_ROOT and MEDIA_URL, if such branding has been configured in settings, else it returns stock branding via static.
nautobot.apps.templatetags.custom_links(context, obj)
¶
Render all applicable links for the given object.
nautobot.apps.templatetags.dbm(value)
¶
Display value as dBm.
nautobot.apps.templatetags.delete_button(instance, use_pk=False, key='slug')
¶
Render a button to delete a model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
BaseModel
|
Model record. |
required |
use_pk
|
bool
|
Used for backwards compatibility, no-op in this function. |
False
|
key
|
str
|
Used for backwards compatibility, no-op in this function. |
'slug'
|
nautobot.apps.templatetags.divide(x, y)
¶
nautobot.apps.templatetags.django_querystring(context, query_dict=None, **kwargs)
¶
Add, remove, and change parameters of a QueryDict and return the result
as a query string. If the query_dict argument is not provided, default
to request.GET.
For example::
{% django_querystring foo=3 %}
To remove a key::
{% django_querystring foo=None %}
To use with pagination::
{% django_querystring page=page_obj.next_page_number %}
A custom QueryDict can also be used::
{% django_querystring my_query_dict foo=3 %}
nautobot.apps.templatetags.edit_button(instance, use_pk=False, key='slug')
¶
Render a button to edit a model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
BaseModel
|
Model record. |
required |
use_pk
|
bool
|
Used for backwards compatibility, no-op in this function. |
False
|
key
|
str
|
Used for backwards compatibility, no-op in this function. |
'slug'
|
nautobot.apps.templatetags.export_button(context, content_type=None, list_element=False)
¶
Display an Export Button/List Element on the page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict
|
current Django Template context |
required |
content_type
|
content_type
|
Django Content Type for the model. Defaults to None. |
None
|
list_element
|
bool
|
Render as a |
False
|
nautobot.apps.templatetags.fgcolor(value)
¶
Return the ideal foreground color (block or white) given an arbitrary background color in RRGGBB format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Color in RRGGBB format, with or without # |
required |
Returns:
| Type | Description |
|---|---|
str
|
ideal foreground color, either black (#000000) or white (#ffffff) |
Example
fgcolor("#999999") "#ffffff"
nautobot.apps.templatetags.format_timezone(time_zone)
¶
Return a human-readable representation of a time zone including
- Time zone name and UTC offset on the first line
- Local date and time on the next line (in smaller font)
nautobot.apps.templatetags.get_docs_url(model)
¶
Return the documentation URL for the specified model, if it can be found/predicted.
- Core models, as of 2.0, are usually at
docs/user-guide/core-data-model/{app_label}/{model_name}.html.- Models in the
extrasapp are usually atdocs/user-guide/platform-functionality/{model_name}.html.
- Models in the
- Apps (plugins) are expected to be documented within their package at
docs/models/{model_name}.htmland are served dynamically through theAppDocsViewendpoint (/docs/<app_name>/<path>).
Any model can define a documentation_static_path class attribute if it needs to override the above expectations.
If a file doesn't exist at the expected static path, this will return None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Instance of a Django model |
required |
Returns:
| Type | Description |
|---|---|
Union[str, None]
|
static URL for the documentation of the object or None if not found. |
Example
get_docs_url(location_instance) "static/docs/user-guide/core-data-model/dcim/location.html" get_docs_url(virtual_server_instance) "static/docs/user-guide/core-data-model/load-balancers/virtualserver.html" get_docs_url(example_model) "/docs/example-app/models/examplemodel.html"
nautobot.apps.templatetags.get_item(d, key)
¶
Access a specific item/key in a dictionary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
dict
|
dictionary containing the data to access |
required |
key
|
str
|
name of the item/key to access |
required |
Returns:
| Type | Description |
|---|---|
any
|
Value of the item in the dictionary provided |
Example
get_item(data, key) "value"
nautobot.apps.templatetags.has_computed_fields(context, obj)
¶
Return a boolean value indicating if an object's content type has associated computed fields.
nautobot.apps.templatetags.has_one_or_more_perms(user, permissions_list)
¶
Return True if the user has at least one permissions in the list.
nautobot.apps.templatetags.has_perms(user, permissions_list)
¶
Return True if the user has all permissions in the list.
nautobot.apps.templatetags.humanize_speed(speed)
¶
Humanize speeds given in Kbps. Examples:
1544 => "1.544 Mbps"
100000 => "100 Mbps"
10000000 => "10 Gbps"
1000000000 => "1 Tbps"
1600000000 => "1.6 Tbps"
10000000000 => "10 Tbps"
nautobot.apps.templatetags.hyperlinked_email(value)
¶
Render an email address as a mailto: hyperlink.
nautobot.apps.templatetags.hyperlinked_field(value, hyperlink=None)
¶
Render a value as a hyperlink.
nautobot.apps.templatetags.hyperlinked_object(value, field='display')
¶
Render and link to a Django model instance, if any, or render a placeholder if not.
Uses the specified object field if available, otherwise uses the string representation of the object.
If the object defines get_absolute_url() this will be used to hyperlink the displayed object;
additionally if there is an object.description this will be used as the title of the hyperlink.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Union[Model, None]
|
Instance of a Django model or None. |
required |
field
|
Optional[str]
|
Name of the field to use for the display value. Defaults to "display". |
'display'
|
Returns:
| Type | Description |
|---|---|
str
|
String representation of the value (hyperlinked if it defines get_absolute_url()) or a placeholder. |
Examples:
>>> hyperlinked_object(device)
'<a href="/dcim/devices/3faafe8c-bdd6-4317-88dc-f791e6988caa/">Device 1</a>'
>>> hyperlinked_object(device_role)
'<a href="/dcim/device-roles/router/" title="Devices that are routers, not switches">Router</a>'
>>> hyperlinked_object(None)
'<span class="text-secondary">—</span>'
>>> hyperlinked_object("Hello")
'Hello'
>>> hyperlinked_object(location)
'<a href="/dcim/locations/leaf/">Root → Intermediate → Leaf</a>'
>>> hyperlinked_object(location, "name")
'<a href="/dcim/locations/leaf/">Leaf</a>'
nautobot.apps.templatetags.hyperlinked_object_target_new_tab(value, field='display')
¶
Render and link to a Django model instance, if any, or render a placeholder if not.
Similar to the hyperlinked_object filter, but passes attributes needed to open the link in new tab.
Uses the specified object field if available, otherwise uses the string representation of the object.
If the object defines get_absolute_url() this will be used to hyperlink the displayed object;
additionally if there is an object.description this will be used as the title of the hyperlink.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Union[Model, None]
|
Instance of a Django model or None. |
required |
field
|
Optional[str]
|
Name of the field to use for the display value. Defaults to "display". |
'display'
|
Returns:
| Type | Description |
|---|---|
str
|
String representation of the value (hyperlinked if it defines get_absolute_url()) or a placeholder. |
Examples:
>>> hyperlinked_object_target_new_tab(device)
'<a href="/dcim/devices/3faafe8c-bdd6-4317-88dc-f791e6988caa/" target="_blank" rel="noreferrer">Device 1</a>'
>>> hyperlinked_object_target_new_tab(device_role)
'<a href="/dcim/device-roles/router/" title="Devices that are routers, not switches" target="_blank" rel="noreferrer">Router</a>'
>>> hyperlinked_object_target_new_tab(None)
'<span class="text-secondary">—</span>'
>>> hyperlinked_object_target_new_tab("Hello")
'Hello'
>>> hyperlinked_object_target_new_tab(location)
'<a href="/dcim/locations/leaf/" target="_blank" rel="noreferrer">Root → Intermediate → Leaf</a>'
>>> hyperlinked_object_target_new_tab(location, "name")
'<a href="/dcim/locations/leaf/" target="_blank" rel="noreferrer">Leaf</a>'
nautobot.apps.templatetags.hyperlinked_object_with_color(obj)
¶
Render the display view of an object.
nautobot.apps.templatetags.hyperlinked_phone_number(value)
¶
Render a phone number as a tel: hyperlink.
nautobot.apps.templatetags.import_button(url)
¶
Deprecated - use job_import_button instead.
nautobot.apps.templatetags.job_buttons(context, obj)
¶
Render all applicable job buttons for the given object.
nautobot.apps.templatetags.job_export_url()
¶
URL to the run view for the Export Object List system job.
Helper to export_button tag, but can be used separately if needed.
nautobot.apps.templatetags.job_import_button(content_type, list_element=False)
¶
Display an Import Button/List Element on the page.
This allows an Import Button to either be displayed on a page or within a Button Group. Args: content_type (str): Django.contrib.ContentType for the model. list_element (bool, optional): Render as a
nautobot.apps.templatetags.job_import_url(content_type)
¶
URL to the run view for the CSV Import system job, prefilled with the given content-type.
Helper to job_import_button tag, but can be used separately if needed.
nautobot.apps.templatetags.label_list(value, suffix='')
¶
Render a list of values with optional suffix (like 'MHz') as span labels.
nautobot.apps.templatetags.log_level(level)
¶
Display a label indicating a syslog severity (e.g. info, warning, etc.).
nautobot.apps.templatetags.meta(obj, attr)
¶
Return the specified Meta attribute of a model. This is needed because Django does not permit templates to access attributes which begin with an underscore (e.g. _meta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Model
|
Class or Instance of a Django Model |
required |
attr
|
str
|
name of the attribute to access |
required |
Returns:
| Type | Description |
|---|---|
any
|
return the value of the attribute |
nautobot.apps.templatetags.meters_to_feet(n)
¶
Convert a length from meters to feet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
(int, float, str)
|
Number of meters to convert |
required |
Returns:
| Type | Description |
|---|---|
float
|
Value in feet |
nautobot.apps.templatetags.modal_form_as_dialog(form, editing=False, form_name=None, obj=None, obj_type=None)
¶
Generate a form in a modal view.
Create an overlaying modal view which holds a Django form.
Inside of the template the template tag needs to be used with the correct inputs. A button will also need to be create to open and close the modal. See below for an example:
{% modal_form_as_dialog form editing=False form_name="CreateDevice" obj=obj obj_type="Device" %}
<a class="btn btn-primary" data-toggle="modal" data-target="#CreateDevice_form" title="Query Form">Create Device</a>
Returns:
| Type | Description |
|---|---|
dict
|
Passed in values used to render HTML. |
nautobot.apps.templatetags.percentage(x, y)
¶
nautobot.apps.templatetags.placeholder(value)
¶
Render a muted placeholder if value is falsey, else render the value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
any
|
Input value, can be any variable. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Placeholder in HTML, or the string representation of the value. |
Example
placeholder("") '—' placeholder("hello") "hello"
nautobot.apps.templatetags.plugin_banners(context)
¶
Render all banners registered by plugins.
nautobot.apps.templatetags.plugin_buttons(context, obj, view='detail')
¶
Render all buttons registered by plugins
nautobot.apps.templatetags.plugin_full_width_page(context, obj)
¶
Render all full width page content registered by plugins
nautobot.apps.templatetags.plugin_left_page(context, obj)
¶
Render all left page content registered by plugins
nautobot.apps.templatetags.plugin_object_detail_tab_content(context, obj)
¶
Render the contents of UI Component Framework Tabs for the object detail view.
nautobot.apps.templatetags.plugin_object_detail_tabs(context, obj)
¶
Render all custom tabs registered by plugins for the object detail view
nautobot.apps.templatetags.plugin_right_page(context, obj)
¶
Render all right page content registered by plugins
nautobot.apps.templatetags.pre_tag(value, format_empty_value=True)
¶
Render a value within <pre></pre> tags to enable formatting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
any
|
Input value, can be any variable. |
required |
format_empty_value
|
bool
|
Whether format empty value or render placeholder. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Value wrapped in |
Example
pre_tag("") '
' pre_tag("hello") 'hello' pre_tag("", format_empty_value=False) '—'
nautobot.apps.templatetags.queryset_to_pks(obj)
¶
Return all object UUIDs as a string separated by ,
nautobot.apps.templatetags.quote_string(value)
¶
Add literal quote characters around the provided value if it's a string.
nautobot.apps.templatetags.render_ancestor_hierarchy(value)
¶
Renders a nested HTML list representing the hierarchy of ancestors for a given object, with an optional location type.
nautobot.apps.templatetags.render_boolean(value)
¶
Render HTML from a computed boolean value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
any
|
Input value, can be any variable. A truthy value (for example non-empty string / True / non-zero number) is considered True. A falsey value other than None (for example "" or 0 or False) is considered False. A value of None is considered neither True nor False. |
required |
Returns:
| Type | Description |
|---|---|
str
|
HTML '' if True value - or - '—' if None value - or - '' if False value |
Examples:
>>> render_boolean(None)
'<span class="text-secondary">—</span>'
>>> render_boolean(True or "arbitrary string" or 1)
'<span class="text-success"><i class="mdi mdi-check-bold" title="Yes"></i></span>'
>>> render_boolean(False or "" or 0)
'<span class="text-danger"><i class="mdi mdi-close-thick" title="No"></i></span>'
nautobot.apps.templatetags.render_breadcrumbs(context, legacy_default_breadcrumbs=None, legacy_block_breadcrumbs=None)
¶
Renders the breadcrumbs using the UI Component Framework or legacy template-defined breadcrumbs.
Function checks if breadcrumbs from UI Component Framework are available and render them but only when there is no other changes coming from legacy template-defined breadcrumbs.
Examples:
- UI Component Framework breadcrumbs are defined in the view. But in the template, {% block breadcrumbs %} is being used,
to override breadcrumbs or {% block extra_breadcrumbs %}. Output: template breadcrumbs will be rendered.
- There is no UI Component Framework breadcrumbs and no other block overrides. Output: default breadcrumbs will be rendered.
- UI Component Framework breadcrumbs are defined in the view. No breadcrumbs block overrides. Output: UI Component Framework breadcrumbs will be rendered.
nautobot.apps.templatetags.render_button_class(value)
¶
Render a string as a styled HTML button using Bootstrap classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
A string representing the button class (e.g., 'primary'). |
required |
Returns:
| Type | Description |
|---|---|
str
|
HTML string for a button with the given class. |
Example
render_button_class("primary") ''
nautobot.apps.templatetags.render_components(context, components)
¶
Render each component in the given components with the given context.
nautobot.apps.templatetags.render_content_types(value)
¶
Render sorted by model and app_label ContentTypes value
nautobot.apps.templatetags.render_custom_fields(form)
¶
Render all custom fields in a form
nautobot.apps.templatetags.render_detail_view_extra_buttons(context)
¶
Render the "extra_buttons" from the context's object_detail_content, or as fallback, from the base detail view.
This makes it possible for "extra" tabs (such as Changelog and Notes, and any added by App TemplateExtensions)
to automatically still render any extra_buttons defined by the base detail view, without the tab-specific views
needing to explicitly inherit from the base view.
nautobot.apps.templatetags.render_field(field, bulk_nullable=False)
¶
Render a single form field from template
nautobot.apps.templatetags.render_form(form, excluded_fields=None)
¶
Render an entire form from template and default to skipping over tags and object_note fields.
Setting excluded_fields to [] prevents skipping over tags and object_note fields
in case they are used as Job variables or DynamicGroup filters.
See:
https://github.com/nautobot/nautobot/issues/4473
https://github.com/nautobot/nautobot/issues/4503
nautobot.apps.templatetags.render_job_run_link(value)
¶
Render the job as a hyperlink to its 'run' view using the class_path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Job
|
The job object. |
required |
Returns:
| Type | Description |
|---|---|
str
|
HTML anchor tag linking to the job's run view. |
nautobot.apps.templatetags.render_json(value, syntax_highlight=True, pretty_print=False)
¶
Render a dictionary as formatted JSON.
Unless syntax_highlight=False is specified, the returned string will be wrapped in a
<code class="language-json> HTML tag to flag it for syntax highlighting by highlight.js.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
any
|
Input value, can be any variable. |
required |
syntax_highlight
|
bool
|
Whether to highlight the JSON syntax or not. |
True
|
pretty_print
|
bool
|
Wraps rendered and highlighted JSON in tag for better code display.
|
False
|
Returns:
| Type | Description |
|---|---|
str
|
HTML
' ' if both syntax_highlight and pretty_print are True
- or -
'{"json_key": "json_value"}' if only pretty_print is True (both syntax_highlight and pretty_print must be True for pretty print)
|
Examples:
>>> render_json({"key": "value"})
'<code class="language-json">{"key": "value"}</code>'
>>> render_json({"key": "value"}, syntax_highlight=False)
'{"key": "value"}'
>>> render_json({"key": "value"}, pretty_print=True)
'<pre><code class="language-json">{"key": "value"}</code></pre>'
>>> render_json({"key": "value"}, syntax_highlight=False, pretty_print=True)
'{"key": "value"}'
nautobot.apps.templatetags.render_markdown(value)
¶
Render text as Markdown
Example
{{ text | render_markdown }}
nautobot.apps.templatetags.render_relationships(form)
¶
Render all relationships in a form
nautobot.apps.templatetags.render_tabs_labels(context, tabs)
¶
Render the tab labels for each Tab in the given tabs with the given context.
nautobot.apps.templatetags.render_tag_attrs(attrs_dict)
¶
Converts tag attributes from a dictionary to a string format suitable for HTML rendering.
nautobot.apps.templatetags.render_title(context, mode='plain')
¶
Render the title passed in the context. Due to backwards compatibility in most of the Generic views,
we're either passing title to the template or render title defined in view_titles.
But in some newer views we want to have simple way to render title, only by defining view_titles within a view class.
nautobot.apps.templatetags.render_uptime(seconds)
¶
Format a value in seconds to a human readable value.
Example
render_uptime(1024768) "11 days 20 hours 39 minutes"
nautobot.apps.templatetags.render_yaml(value, syntax_highlight=True)
¶
Render a dictionary as formatted YAML.
Unless syntax_highlight=False is specified, the returned string will be wrapped in a
<code class="language-yaml> HTML tag to flag it for syntax highlighting by highlight.js.
nautobot.apps.templatetags.saved_view_title(context, mode='html')
¶
Creates a formatted title that includes saved view information. Usage:
{{ title }}{% saved_view_title "html" %}
nautobot.apps.templatetags.settings_or_config(key, app_name=None)
¶
Get a value from Django settings (if specified there) or Constance configuration (otherwise).
nautobot.apps.templatetags.slugify(value)
¶
Return a slugified version of the value.
nautobot.apps.templatetags.split(string, sep=',')
¶
Split a string by the given value (default: comma)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string
|
str
|
string to split into a list |
required |
sep
|
str default=,
|
separator to look for in the string |
','
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of string, if the separator wasn't found, list of 1 |
nautobot.apps.templatetags.support_message()
¶
Return the configured support message (if any) or else the default.
nautobot.apps.templatetags.tag(tag, url_name=None)
¶
Display a tag, optionally linked to a filtered list of objects.
nautobot.apps.templatetags.tree_hierarchy_ui_representation(tree_depth, hide_hierarchy_ui, base_depth=0)
¶
Generates a visual representation of a tree record hierarchy using dots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tree_depth
|
range
|
A range representing the depth of the tree nodes. |
required |
hide_hierarchy_ui
|
bool
|
Indicates whether to hide the hierarchy UI. |
required |
base_depth
|
int
|
Starting depth (number of dots to skip rendering). |
0
|
Returns:
| Type | Description |
|---|---|
str
|
A string containing dots (representing hierarchy levels) if |
nautobot.apps.templatetags.tzoffset(value)
¶
Returns the hour offset of a given time zone using the current time.
nautobot.apps.templatetags.utilization_graph(utilization_data, warning_threshold=75, danger_threshold=90)
¶
Wrapper for a horizontal bar graph indicating a percentage of utilization from a tuple of data.
Takes the utilization_data that is a namedtuple with numerator and denominator field names and passes them into the utilization_graph_raw_data to handle the generation graph data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utilization_data
|
UtilizationData
|
Namedtuple with numerator and denominator keys |
required |
warning_threshold
|
int
|
Warning Threshold Value. Defaults to 75. |
75
|
danger_threshold
|
int
|
Danger Threshold Value. Defaults to 90. |
90
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with utilization, warning threshold, danger threshold, utilization count, and total count for display |
nautobot.apps.templatetags.utilization_graph_raw_data(numerator, denominator, warning_threshold=75, danger_threshold=90)
¶
Display a horizontal bar graph indicating a percentage of utilization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
numerator
|
int
|
Numerator for creating a percentage |
required |
denominator
|
int
|
Denominator for creating a percentage |
required |
warning_threshold
|
int
|
Warning Threshold Value. Defaults to 75. |
75
|
danger_threshold
|
int
|
Danger Threshold Value. Defaults to 90. |
90
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with utilization, warning threshold, danger threshold, utilization count, and total count for display |
nautobot.apps.templatetags.validated_api_viewname(model, action)
¶
Return the API view name for the given model and action if valid, or None if invalid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Class or Instance of a Django Model |
required |
action
|
str
|
name of the action in the viewname |
required |
Returns:
| Type | Description |
|---|---|
Union[str, None]
|
return the name of the API view for the model/action provided if valid, or None if invalid. |
nautobot.apps.templatetags.validated_viewname(model, action)
¶
Return the view name for the given model and action if valid, or None if invalid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Class or Instance of a Django Model |
required |
action
|
str
|
name of the action in the viewname |
required |
Returns:
| Type | Description |
|---|---|
Union[str, None]
|
return the name of the view for the model/action provided if valid, or None if invalid. |
nautobot.apps.templatetags.versioned_static(file_path)
¶
Returns a versioned static file URL with a query parameter containing the version number.
nautobot.apps.templatetags.viewname(model, action)
¶
Return the view name for the given model and action. Does not perform any validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Class or Instance of a Django Model |
required |
action
|
str
|
name of the action in the viewname |
required |
Returns:
| Type | Description |
|---|---|
str
|
return the name of the view for the model/action provided. |
Examples: >>> viewname(Device, "list") "dcim:device_list"
nautobot.apps.templatetags.widget_type(field)
¶
Return the widget type