Permalink
Browse files

Allow searching for tags by name as well as id

  • Loading branch information...
Rob Fisher
Rob Fisher committed May 10, 2012
1 parent fceeb9c commit 2444f2a760bf89117f93fe6f8117733a2c6bd42e
Showing with 9 additions and 1 deletion.
  1. +9 −1 mailshareapp/search.py
View
@@ -125,7 +125,15 @@ class _TagParameter(_Parameter):
def __init__(self, value, index, search):
super(_TagParameter, self).__init__(value, index, search)
- self.tid = int(value)
+ try:
+ self.tid = int(value)
+ except ValueError:
+ self.name = value
+ try:
+ tag = models.Tag.objects.get(name=self.name)
+ self.tid = tag.id
+ except models.Tag.DoesNotExist:
+ self.tid = 0
def get_query(self):

0 comments on commit 2444f2a

Please sign in to comment.