Q:

How do I access a Django model attribute within the model class definition?

The problem with this code is that when I try to access self.username I get a 
NameError: 'self' is not defined

The username attribute is inherited from Django's AbstractUser.
I did some googling and found that I needed to make an init method in order for the self variable to exist. The problem is that I do not want to do anything in the init since the rest of my Django code handled the instantiation already and my application is working as is. I tried making an init method with just 'pass' but this also gives me the same error.
Is there any way I can access my attribute without seriously changing the model or making new migrations? I am using Django 2.0 on a Windows 10 OS.

A:

Just avoid the string path concatenation on the upload_to, and move your method out of class
def profile_pic_path(instance, filename):
    return 'users/{0}/{1}'.format(instance.username, filename)

class Profile(models.Model):
    #other fields
    profile_picture = models.FileField(upload_to=profile_pic_path)

