from django.conf import settings

# third party
import uuid
import os


def getRandomCode():
    code = str(uuid.uuid4())[:8].replace('-', '').lower()
    return code


def userAvatarPath(instance, filename):
    avatar_pic_name = f'avatars/user_{instance.user.id}-{instance.user}/avatar_{filename}'
    full_path = os.path.join(settings.MEDIA_ROOT, avatar_pic_name)

    if os.path.exists(full_path):
        os.remove(full_path)

    return avatar_pic_name

92c4a15d25abe7fbbf26a463325612f9a2990c8d
<mask token>

<mask token>


def userAvatarPath(instance, filename):
    avatar_pic_name = (
        f'avatars/user_{instance.user.id}-{instance.user}/avatar_{filename}')
    full_path = os.path.join(settings.MEDIA_ROOT, avatar_pic_name)
    if os.path.exists(full_path):
        os.remove(full_path)
    return avatar_pic_name

<mask token>


def getRandomCode():
    code = str(uuid.uuid4())[:8].replace('-', '').lower()
    return code


def userAvatarPath(instance, filename):
    avatar_pic_name = (
        f'avatars/user_{instance.user.id}-{instance.user}/avatar_{filename}')
    full_path = os.path.join(settings.MEDIA_ROOT, avatar_pic_name)
    if os.path.exists(full_path):
        os.remove(full_path)
    return avatar_pic_name

from django.conf import settings
import uuid
import os


def getRandomCode():
    code = str(uuid.uuid4())[:8].replace('-', '').lower()
    return code


def userAvatarPath(instance, filename):
    avatar_pic_name = (
        f'avatars/user_{instance.user.id}-{instance.user}/avatar_{filename}')
    full_path = os.path.join(settings.MEDIA_ROOT, avatar_pic_name)
    if os.path.exists(full_path):
        os.remove(full_path)
    return avatar_pic_name

from django.conf import settings

# third party
import uuid
import os


def getRandomCode():
    code = str(uuid.uuid4())[:8].replace('-', '').lower()
    return code


def userAvatarPath(instance, filename):
    avatar_pic_name = f'avatars/user_{instance.user.id}-{instance.user}/avatar_{filename}'
    full_path = os.path.join(settings.MEDIA_ROOT, avatar_pic_name)

    if os.path.exists(full_path):
        os.remove(full_path)

    return avatar_pic_name
