Skip to content

Commit

Permalink
models: Don't query a related field in __unicode__
Browse files Browse the repository at this point in the history
Turns out that str(object) is used when putting 'object' in the
template context. Because of revisions __unicode__ was using series.name
we were doing as many queries as revisions in the detailed series page,
without actually using that string representation anywhere.

Because the string representation of SeriesRevision is not very useful,
let's just get rid of that query altogether.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
  • Loading branch information
Damien Lespiau committed Nov 3, 2015
1 parent f01fd73 commit 6714f34
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions patchwork/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,7 @@ def duplicate(self, exclude_patches=()):
return new

def __unicode__(self):
if hasattr(self, 'series'):
return self.series.name + " (rev " + str(self.version) + ")"
else:
return "New revision" + " (rev " + str(self.version) + ")"
return "Revision " + self.version

class SeriesRevisionPatch(models.Model):
patch = models.ForeignKey(Patch)
Expand Down

0 comments on commit 6714f34

Please sign in to comment.