def by_date(instance, filename): datepart = force_text(now().strftime("%Y/%m/%d")) return os.path.join(datepart, get_valid_filename(filename))