def _get_absolute_url(self, view='t'):
return reverse('show_album', args=[view, str(
self.id)]) + self.url
Of course I can concatenate {% url %} with album.url right in the template to archive the same results, but I believe this would be a really bad practice. The obvious solution is to pass an argument to get_absolute_url. This is what my question was about. Since it's impossible, I'll remain with what I already have:
def _get_absolute_url(self, view='t'):
return reverse('show_album', args=[view, str(
self.id)]) + self.url
def get_absolute_url_f(self):
return self._get_absolute_url('f')
def get_absolute_url_t(self):
return self._get_absolute_url('t')
def get_absolute_url(self):
return self._get_absolute_url()
Not very nice but at least it works.
Thank you for your answer, I really appreciate your advice.
четверг, 31 января 2013 г., 15:42:28 UTC+4 пользователь Daniel Roseman написал: