Here's my model. What I want to do is generate a new file and overwrite the existing one whenever a model instance is saved:
class Kitten(models.Model):
claw_size = ...
license_file = models.FileField(blank=True, upload_to='license')
def save(self, *args, **kwargs):
#Generate a new license file overwriting any previous version
#and update file path
self.license_file = ???
super(Request,self).save(*args, **kwargs)
I see lots of documentation about how to upload a file. But how do I generate a file, assign it to a model field and have Django store it in the right place?