Mercurial > public > sg101
comparison polls/models.py @ 1035:eeaf387803c6
Remove usages of @models.permalink.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 26 Dec 2015 21:33:55 -0600 |
parents | ee87ea74d46b |
children |
comparison
equal
deleted
inserted
replaced
1034:2f36abf65a62 | 1035:eeaf387803c6 |
---|---|
3 | 3 |
4 """ | 4 """ |
5 import datetime | 5 import datetime |
6 | 6 |
7 from django.contrib.auth.models import User | 7 from django.contrib.auth.models import User |
8 from django.core.urlresolvers import reverse | |
8 from django.db import models | 9 from django.db import models |
9 from django.db.models import Q | 10 from django.db.models import Q |
10 | 11 |
11 | 12 |
12 class PollManager(models.Manager): | 13 class PollManager(models.Manager): |
45 | 46 |
46 class Meta: | 47 class Meta: |
47 ordering = ('-start_date', ) | 48 ordering = ('-start_date', ) |
48 get_latest_by = 'start_date' | 49 get_latest_by = 'start_date' |
49 | 50 |
50 @models.permalink | |
51 def get_absolute_url(self): | 51 def get_absolute_url(self): |
52 return ('polls-detail', [], {'poll_id': str(self.id)}) | 52 return reverse('polls-detail', kwargs={'poll_id': str(self.pk)}) |
53 | 53 |
54 def results(self): | 54 def results(self): |
55 """ | 55 """ |
56 Returns a tuple; element 0 is the total votes, element 1 is a list of | 56 Returns a tuple; element 0 is the total votes, element 1 is a list of |
57 {choice, votes, pct} | 57 {choice, votes, pct} |