[Answer]-Trouble with django upload_to callable

1👍

Your test isn’t actually testing the right thing. The upload_to callable is called when you upload a file, as the name implies, not when you simply save the model. You need to try with an actual upload: perhaps try through the admin site.

When you do, you will almost certainly run into problems because Python will think that the function is an instance method, because you have defined it inside the class. You’ll need to take it outside of the class, or decorate it with @staticmethod.

Leave a comment