15👍
There is an attribute app_label
in _meta
attribute. Please see this stackoverflow question
3👍
from os import path
def _get_upload_to(instance, filename):
return path.join(instance._meta.app_label, 'subdir', filename)
class MyModel(models.Model):
....
datoteka = models.FileField(upload_to=_get_upload_to, ...)
Will result in ‘MyApp/subdir’ upload path.
Source:stackexchange.com