diff --git a/accounts/views/delete.py b/accounts/views/delete.py index 30b4c7c..9a83800 100644 --- a/accounts/views/delete.py +++ b/accounts/views/delete.py @@ -1,6 +1,7 @@ from rest_framework.views import APIView from rest_framework import permissions, status from rest_framework.response import Response +from django.contrib.auth import logout from django.http import HttpRequest from rest_framework.authentication import SessionAuthentication @@ -16,4 +17,5 @@ class DeleteView(APIView): if (request.user.check_password(password) == False): return Response({"password": ["Password wrong."]}) request.user.delete() + logout(request) return Response("user deleted", status=status.HTTP_200_OK) \ No newline at end of file diff --git a/profiles/models.py b/profiles/models.py index 3c12017..31df212 100644 --- a/profiles/models.py +++ b/profiles/models.py @@ -11,7 +11,7 @@ def upload_to(instance, filename: str): # Create your models here. class ProfileModel(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) - avatar_url = models.ImageField(upload_to=upload_to, default="../static/avatars/default.avif") #blank=True, null=True) + avatar_url = models.ImageField(upload_to=upload_to, default="./profiles/static/avatars/default.avif") #blank=True, null=True) @receiver(post_save, sender=User) def on_user_created(sender, instance, created, **kwargs): diff --git a/profiles/viewsets.py b/profiles/viewsets.py index 03d8858..d9500aa 100644 --- a/profiles/viewsets.py +++ b/profiles/viewsets.py @@ -38,7 +38,7 @@ class ProfileViewSet(viewsets.ModelViewSet): profile: ProfileModel = ProfileModel.objects.get(pk=self.request.user.pk) avatar = self.request.data.get("file", None) if (avatar is not None): - if (profile.avatar_url.name != "default.avif"): + if (profile.avatar_url.name != "./profiles/static/avatars/default.avif"): profile.avatar_url.storage.delete(profile.avatar_url.name) profile.avatar_url = avatar profile.save() \ No newline at end of file