Is it possible to define the upload_to path of an ImageField based on a CharField in the same model? For example:
class Profile(models.Model):
def make_image_path(pathfolder):
image_path = f"users/{pathfolder}/"
return image_path
username = models.CharField(max_length=50, unique=True)
photo = models.ImageField(upload_to=make_image_path(username))
This currently works except result is users/<django.db.models.fields.CharField>/picture.jpeg
How can I make it show the username instead of <django.db.models.fields.CharField>.