1 from django.core.urlresolvers import reverse
2 from django.db import models
3 from django.utils.translation import ugettext_lazy as _
7 (u'lawful', u'Lawful'),
8 (u'neutral', u'Neutral'),
9 (u'chaotic', u'Chaotic'),
13 class Word(models.Model):
14 word = models.CharField(_('word'), max_length=255, db_index=True)
15 slug = models.SlugField(_('slug'), unique=True)
16 alignment = models.CharField(_('alignment'), max_length=64, choices=ALIGNMENTS)
17 examples = models.TextField(_('examples'))
18 usage = models.TextField(_('usage'))
19 recommendations = models.TextField(_('recommendations'))
22 verbose_name = _('word')
23 verbose_name_plural = _('words')
26 def __unicode__(self):
29 def get_absolute_url(self):
30 return reverse('words_word', args=[self.slug])
34 return Word.objects.filter(word__gt=self.word)[0]
36 return Word.objects.all()[0]
38 def get_previous(self):
39 words = Word.objects.order_by('-word')
41 return words.filter(word__lt=self.word)[0]