1👍
✅
Checking the sources of django-avatar, your error came from this line: https://github.com/jazzband/django-avatar/blob/main/avatar/providers.py#L77
Did you change the value of settings.AVATAR_GRAVATAR_FIELD
? If yes, what is the value of this field for the user you tried to display an avatar. If not, what is the value of field email
(the default for settings.AVATAR_GRAVATAR_FIELD
) for that user ?
Looking at the code :
def get_avatar_url(cls, user, width, _height=None):
email = getattr(user, settings.AVATAR_GRAVATAR_FIELD).encode("utf-8")
_, domain = email.split(b"@")
it appear that the email value returned by getattr(user, settings.AVATAR_GRAVATAR_FIELD)
does not contain any @
character. This may be caused by an invalid value in your database.
See :
>>> email = "foo@bar.com".encode("utf-8")
>>> email.split(b"@")
[b'foo', b'bar.com']
>>> email = "invalid_email.com".encode("utf-8")
>>> email.split(b"@")
[b'invalid_email.com']
>>> _, domain = email.split(b"@")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: not enough values to unpack (expected 2, got 1)
Source:stackexchange.com