I know that you can use the upload_to parameter to pass a callable function to dynamically alter a FileFied/ImageField, etc. in a Django model.
The function called
The instance
variable is the Badge()
instance. You could access it's properties as usual
def format_badge_name(instance, filename):
instance.name
instance.file
...
You could name the instance
'self'
, and it might be easier to be understood:
def format_badge_name(self, filename):
self.name
self.file
...