1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #169: Fallback to cancel_url if object is missing get_absolute_url()

This commit is contained in:
Jeremy Stretch
2016-07-01 10:25:13 -04:00
parent 7a68e1d901
commit 1bb2a3f152

View File

@ -120,7 +120,7 @@ class ObjectEditView(View):
'obj': obj,
'obj_type': self.model._meta.verbose_name,
'form': form,
'cancel_url': obj.get_absolute_url() if obj else reverse(self.cancel_url),
'cancel_url': obj.get_absolute_url() if hasattr(obj, 'get_absolute_url') else reverse(self.cancel_url),
})
def post(self, request, *args, **kwargs):
@ -157,7 +157,7 @@ class ObjectEditView(View):
'obj': obj,
'obj_type': self.model._meta.verbose_name,
'form': form,
'cancel_url': obj.get_absolute_url() if obj else reverse(self.cancel_url),
'cancel_url': obj.get_absolute_url() if hasattr(obj, 'get_absolute_url') else reverse(self.cancel_url),
})