jinja2/django IPAddress has no parent object #15625
-
Trying to get IPs from parent prefix - this works fine via API - doesn't look like it's being exposed in django API: list(nb.ipam.ip_addresses.filter(parent=test.prefix, description="test")) {{ipam.IPAddress.objects.filter(parent=test.prefix, description="test")}} Error: <class 'django.core.exceptions.FieldError'> Cannot resolve keyword 'parent' into field. Choices are: address, assigned_object, assigned_object_id, assigned_object_type, assigned_object_type_id, bookmarks, comments, created, custom_field_data, description, dns_name, fhrpgroup, id, interface, journal_entries, last_updated, local_address, nat_inside, nat_inside_id, nat_outside, remote_address, role, services, status, tagged_items, tags, tenant, tenant_id, vminterface, vrf, vrf_id Python version: 3.8.12 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
There is no directly 'parent' database relationship between IPAddress and Prefix. If you want to do it in Django ORM, you need to duplicate what the Netbox REST API filters are doing. For example, the parent filter on IPAddress is here. You can some find some more examples in this script (not yet merged). |
Beta Was this translation helpful? Give feedback.
That's part of Django, I don't think you can hack the Django filters (easily). In any case, what you want is already available, just under a different name: