django-avatar icon indicating copy to clipboard operation
django-avatar copied to clipboard

When a user is not found, get_primary_avatar() returns a string instead of an avatar object.

Open danostrowski opened this issue 15 years ago • 1 comments
trafficstars

When the below code is run (which results if you pass in a user that doesn't exist... I put User ID instead of username in the render_primary view) it will return a "default url" which is a string. The view then tries to use the result as if it was an avatar object and it ... explodes.

avatar.util on tip

def get_primary_avatar(user, size=80): if not isinstance(user, User): try: user = User.objects.get(username=user) except User.DoesNotExist: return get_default_avatar_url() # <~~~ inappropriate return type.

danostrowski avatar Feb 25 '10 00:02 danostrowski

You're right, I fixed it in http://github.com/liberation/django-avatar/commit/47a3856e8e50fd6fd984c7676885b40d586a4629

Working on the corresponding tests to make sure it doesn't happen again.

diox avatar Feb 25 '10 11:02 diox

Has been fixed.

johanneswilm avatar Aug 16 '22 10:08 johanneswilm