Always save profile image to save filename for user

parent 225b061f
...@@ -190,6 +190,10 @@ class Member(User): ...@@ -190,6 +190,10 @@ class Member(User):
return reverse('members:profile', args=[str(self.pk)]) return reverse('members:profile', args=[str(self.pk)])
def _profile_image_path(instance, filename):
return f'public/avatars/{instance.pk}'
class Profile(models.Model): class Profile(models.Model):
"""This class holds extra information about a member""" """This class holds extra information about a member"""
...@@ -364,7 +368,7 @@ class Profile(models.Model): ...@@ -364,7 +368,7 @@ class Profile(models.Model):
photo = models.ImageField( photo = models.ImageField(
verbose_name=_('Photo'), verbose_name=_('Photo'),
upload_to='public/avatars/', upload_to=_profile_image_path,
null=True, null=True,
blank=True, blank=True,
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment