Skip to content

Commit

Permalink
Fixes #169: Fallback to cancel_url if object is missing get_absolute_…
Browse files Browse the repository at this point in the history
…url()
  • Loading branch information
jeremystretch committed Jul 1, 2016
1 parent 7a68e1d commit 1bb2a3f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions netbox/utilities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def get(self, request, *args, **kwargs):
'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):
Expand Down Expand Up @@ -157,7 +157,7 @@ def post(self, request, *args, **kwargs):
'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),
})


Expand Down

0 comments on commit 1bb2a3f

Please sign in to comment.