django-whatever
django-whatever copied to clipboard
Callable file upload_to
I have in model
def upload_userfile_path(instance, filename):
return 'files/%s/%s' % (instance.user.id, filename)
class UserFile(models.Model):
user = models.ForeignKey(User)
file = models.FileField(upload_to=upload_userfile_path)
in test
user = any_model(User, is_active=True)
any_model(UserFile, user=user)
And error as result:
AttributeError: 'NoneType' object has no attribute 'user'
at generated_filepath = field.upload_to(None, xunit.any_string(ascii_letters, 10, 20))
Callable upload_to doesn't work with instance argument yet. I don't have time to fix it myself right now, but I'd love to merge if anyone is willing to fix it.