mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Handle the MultipleObjectsReturned edge case (shouldn't happen, but it might)
git-svn-id: http://django-avatar.googlecode.com/svn/trunk@15 c76b2324-5f53-0410-85ac-b1078a54aeeb
This commit is contained in:
parent
3ac9b98cb2
commit
97ebeaaa53
1 changed files with 3 additions and 0 deletions
|
|
@ -29,6 +29,7 @@ except ImportError:
|
|||
MAX_MEGABYTES = getattr(settings, 'AVATAR_MAX_FILESIZE', 10)
|
||||
MAX_WIDTH = getattr(settings, 'AVATAR_MAX_WIDTH', 512)
|
||||
DEFAULT_WIDTH = getattr(settings, 'AVATAR_DEFAULT_WIDTH', 80)
|
||||
#AVATAR_CACHE
|
||||
|
||||
def _get_next(request):
|
||||
"""
|
||||
|
|
@ -66,6 +67,8 @@ def img(request, email_hash, resize_method=Image.ANTIALIAS):
|
|||
avatar = Avatar.objects.get(email_hash=email_hash)
|
||||
except Avatar.DoesNotExist:
|
||||
avatar = None
|
||||
except Avatar.MultipleObjectsReturned:
|
||||
avatar = None
|
||||
try:
|
||||
if avatar is not None:
|
||||
data = open(avatar.get_avatar_filename(), 'r').read()
|
||||
|
|
|
|||
Loading…
Reference in a new issue