Mercurial > public > sg101
comparison gpp/forums/models.py @ 552:9e42e6618168
For bitbucket issue #2, tweak the admin settings for the Post model to
reduce slow queries. Define our own queryset() method so we can control the
select_related(), and not have it cascade from post to topics to forums to
categories. Removed 'topic' from list_display because MySQL still sucked with
2 inner joins. Now it seems to be tolerable with only one join to User.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 25 Jan 2012 20:07:03 -0600 |
parents | 7388cdf61b25 |
children | 70722b7d10af |
comparison
equal
deleted
inserted
replaced
551:f37ef598fecc | 552:9e42e6618168 |
---|---|
279 @models.permalink | 279 @models.permalink |
280 def get_absolute_url(self): | 280 def get_absolute_url(self): |
281 return ('forums-goto_post', [self.pk]) | 281 return ('forums-goto_post', [self.pk]) |
282 | 282 |
283 def summary(self): | 283 def summary(self): |
284 LIMIT = 50 | 284 limit = 65 |
285 if len(self.body) < LIMIT: | 285 if len(self.body) < limit: |
286 return self.body | 286 return self.body |
287 return self.body[:LIMIT] + '...' | 287 return self.body[:limit] + '...' |
288 | 288 |
289 def __unicode__(self): | 289 def __unicode__(self): |
290 return self.summary() | 290 return self.summary() |
291 | 291 |
292 def save(self, *args, **kwargs): | 292 def save(self, *args, **kwargs): |