Fix AttributeError: 'str' object has no attribute 'ip' in signals.py

This commit is contained in:
Sander Steffann 2020-06-24 12:39:06 +02:00
parent 77a466ef2c
commit adfa056939
2 changed files with 3 additions and 3 deletions

View file

@ -1,4 +1,4 @@
VERSION = '1.0.1' VERSION = '1.0.2'
try: try:
from extras.plugins import PluginConfig from extras.plugins import PluginConfig

View file

@ -1,7 +1,7 @@
import logging import logging
from django.db.models.signals import post_delete, post_save, pre_save from django.db.models.signals import post_delete, post_save, pre_save
from django.dispatch import receiver from django.dispatch import receiver
from netaddr import IPNetwork
from ipam.models import IPAddress from ipam.models import IPAddress
from netbox_ddns.background_tasks import dns_create, dns_delete from netbox_ddns.background_tasks import dns_create, dns_delete
@ -21,7 +21,7 @@ def trigger_ddns_update(instance: IPAddress, **_kwargs):
old_address = instance.before_save.address.ip if instance.before_save else None old_address = instance.before_save.address.ip if instance.before_save else None
old_dns_name = normalize_fqdn(instance.before_save.dns_name) if instance.before_save else '' old_dns_name = normalize_fqdn(instance.before_save.dns_name) if instance.before_save else ''
new_address = instance.address.ip new_address = IPNetwork(instance.address).ip
new_dns_name = normalize_fqdn(instance.dns_name) new_dns_name = normalize_fqdn(instance.dns_name)
extra_dns_names = {normalize_fqdn(extra.name): extra for extra in instance.extradnsname_set.all()} extra_dns_names = {normalize_fqdn(extra.name): extra for extra in instance.extradnsname_set.all()}