def get_absolute_url(self):
return reverse('words_word', args=[self.slug])
+
+ def get_next(self):
+ try:
+ return Word.objects.filter(word__gt=self.word)[0]
+ except IndexError:
+ return Word.objects.all()[0]
+
+ def get_previous(self):
+ words = Word.objects.order_by('-word')
+ try:
+ return words.filter(word__lt=self.word)[0]
+ except IndexError:
+ return words[0]