Browse files

fixed error of get_by_slug

  • Loading branch information...
1 parent d789680 commit 546e0b092a20f641250721d5629de8d5061ef599 @ramusus committed Dec 21, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 vkontakte_api/models.py
View
4 vkontakte_api/models.py
@@ -44,8 +44,8 @@ def get_by_slug(self, slug):
'''
try:
assert self.model.slug_prefix and slug.startswith(self.model.slug_prefix)
- remote_id = int(slug.replace(self.model.slug_prefix, ''))
- except (AssertionError, ValueError):
+ remote_id = int(re.findall(r'^%s(\d+)$' % self.model.slug_prefix, slug)[0])
+ except (AssertionError, ValueError, IndexError):
try:
return self.model.objects.get(screen_name=slug)
except self.model.DoesNotExist:

0 comments on commit 546e0b0

Please sign in to comment.