Skip to content

Commit

Permalink
Added helper to resolve the named url.
Browse files Browse the repository at this point in the history
  • Loading branch information
miracle2k committed Dec 9, 2009
1 parent 1038fb2 commit ba8cee8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions flatblocks/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.cache import cache
from django.core.urlresolvers import reverse

from flatblocks.settings import CACHE_PREFIX

Expand Down Expand Up @@ -32,3 +33,11 @@ def save(self, *args, **kwargs):
class Meta:
verbose_name = _('Flat block')
verbose_name_plural = _('Flat blocks')

def get_url(self):
if not hasattr(self, '_url'):
if self.named_url:
self._url = reverse(self.named_url)
else:
self._url = self.url
return self._url

0 comments on commit ba8cee8

Please sign in to comment.