|
@@ -53,16 +53,19 @@ Model classes (e.g. `dcim.Site`) aren't available, and each variable provided by
|
|
|
|
|
|
|
|
In legacy mode, `objects` and `user` are also provided, so templates can be migrated one at a time before switching modes. Common changes needed when migrating a template:
|
|
In legacy mode, `objects` and `user` are also provided, so templates can be migrated one at a time before switching modes. Common changes needed when migrating a template:
|
|
|
|
|
|
|
|
-| Legacy | Restricted |
|
|
|
|
|
-|------------------------------------------------------------------------|--------------------------------------------------------------------------------|
|
|
|
|
|
-| `{% for d in queryset %}` | `{% for d in objects %}` |
|
|
|
|
|
-| `{{ d.cf.foo }}` | `{{ d.custom_fields.foo }}` |
|
|
|
|
|
-| `{{ d.get_absolute_url() }}` | `{{ d.display_url }}` |
|
|
|
|
|
-| `{{ d.get_status_display() }}` | `{{ d.status.label }}` |
|
|
|
|
|
-| `{{ d.get_config_context() }}` | `{{ d.config_context }}` |
|
|
|
|
|
-| `{{ prefix.get_child_ips().filter(interface__name='Bu1').first() }}` | `{{ query('ipam.ipaddress', parent=prefix.prefix, interface='Bu1').first() }}` |
|
|
|
|
|
-| `{{ prefix.get_child_ranges().first() }}` | `{{ query('ipam.iprange', parent=prefix.prefix).first() }}` |
|
|
|
|
|
-| `{% if prefix.tags.contains(extras.Tag.objects.get(slug='static')) %}` | `{% if 'static' in prefix.tags \| map(attribute='slug') %}` |
|
|
|
|
|
|
|
+| Legacy | Restricted |
|
|
|
|
|
+|------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
|
|
|
|
|
+| `{% for d in queryset %}` | `{% for d in objects %}` |
|
|
|
|
|
+| `{{ d.cf.foo }}` | `{{ d.custom_fields.foo }}` |
|
|
|
|
|
+| `{{ d.get_absolute_url() }}` | `{{ d.display_url }}` |
|
|
|
|
|
+| `{{ d.get_status_display() }}` | `{{ d.status.label }}` |
|
|
|
|
|
+| `{{ d.get_config_context() }}` | `{{ d.config_context }}` |
|
|
|
|
|
+| `{{ prefix.get_child_ips().filter(interface__name='Bu1').first() }}` | `{{ query('ipam.ipaddress', parent=prefix.prefix, vrf_id=vrf_id, interface='Bu1').first() }}` |
|
|
|
|
|
+| `{{ prefix.get_child_ranges().first() }}` | `{{ query('ipam.iprange', parent=prefix.prefix, vrf_id=vrf_id).first() }}` |
|
|
|
|
|
+| `{% if prefix.tags.contains(extras.Tag.objects.get(slug='static')) %}` | `{% if 'static' in prefix.tags \| map(attribute='slug') %}` |
|
|
|
|
|
+| `{{ prefix.get_utilization() }}` | No equivalent (see [`TEMPLATE_RENDERING`](../configuration/system.md#template_rendering)) |
|
|
|
|
|
+
|
|
|
|
|
+`get_child_ips()` and `get_child_ranges()` return only the objects in the prefix's VRF, so pass its ID as `vrf_id`, or `None` for the global table (e.g. `{% set vrf_id = prefix.vrf.id if prefix.vrf else None %}`). The exception is a container prefix in the global table, for which `get_child_ips()` returns IP addresses in any VRF: omit `vrf_id` to match it.
|
|
|
|
|
|
|
|
## REST API Integration
|
|
## REST API Integration
|
|
|
|
|
|