2👍
✅
Don’t worry about replacing upload_to
just modify the method to handle different subclasses (use a method for upload_to
if you’re not already).
def my_upload_to(instance, filename):
if instance._meta.module_name == 'homework':
return '/path/to/homework/files/%s' % filename
if instance._meta.module_name == 'classpaper':
return '/path/to/classpaper/files/%s' % filename
if instance._meta.module_name == 'randompaper':
return '/path/to/randompaper/files/%s' % filename
Source:stackexchange.com