Skip to content

Commit

Permalink
Update the default avatar method
Browse files Browse the repository at this point in the history
  • Loading branch information
alissatroiano committed Jul 18, 2021
1 parent 561932c commit 3f89a7b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions profiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,15 @@ class Profile(models.Model):
default_county = models.CharField(max_length=80, null=True, blank=True)
avatar = models.ImageField(upload_to ='avatars', default="avatar.jpg")


def create_default_avatar(self):
if not self.avatar_set.all():
avatar = profile.avatar_set.create(profile=self.__class__)
avatar.avatar = File(open('media/default_profile_picture.jpg'))
avatar.avatar_thumbnail = File(open('media/default_profile_picture_thumbnail.jpg'))
avatar.avatar = File(open('media/avatar.jpg'))
avatar.avatar_thumbnail = File(open('media/avatar.jpg'))
avatar.save()

def __str__(self):
return self.user.username




@receiver(post_save, sender=User)
def create_or_update_user_profile(sender, instance, created, **kwargs):
Expand Down

0 comments on commit 3f89a7b

Please sign in to comment.