Skip to content

Commit

Permalink
Fix for get_public_absolute_url for Django 1.4+
Browse files Browse the repository at this point in the history
This was letting django templates deal with attribute error, rather than
checking whether get_absolute_url existed.
  • Loading branch information
johnsensible committed Sep 26, 2013
1 parent d347373 commit 82121ae
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion publish/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ def is_marked_for_deletion(self):

def get_public_absolute_url(self):
if self.public:
return self.public.get_absolute_url()
get_absolute_url = getattr(self.public, 'get_absolute_url', None)
if get_absolute_url:
return get_absolute_url()
return None

def save(self, mark_changed=True, *arg, **kw):
Expand Down

0 comments on commit 82121ae

Please sign in to comment.