mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Change profile photo filename
This commit is contained in:
parent
447b034d38
commit
fd08e3c58a
1 changed files with 1 additions and 3 deletions
|
@ -20,11 +20,9 @@ def validate_student_id(value):
|
|||
class CustomUser(AbstractUser):
|
||||
def _get_upload_to(instance, filename):
|
||||
base_filename, file_extension = os.path.splitext(filename)
|
||||
# Convert filename to a slug format
|
||||
cleaned_filename = slugify(base_filename)
|
||||
# Get the student ID number
|
||||
student_id = str(instance.student_id_number)
|
||||
new_filename = f"{student_id}_{cleaned_filename}{file_extension}"
|
||||
new_filename = f"{student_id}_{file_extension}"
|
||||
return os.path.join('avatars', new_filename)
|
||||
|
||||
first_name = models.CharField(max_length=100)
|
||||
|
|
Loading…
Reference in a new issue