I have to create and save django model containing filefield with a downloaded attachment.
somefield = models.FileField(upload_to='somefolder/%Y/%m/%d')
I have downloaded the attachment but when I give path to the downloaded attachment as filefield upload to argument, attachment is not getting saved. I checked the folder and could not find the file.
My procedure is as follows
1.Download attachment and save it.
2.Call Model with filefield.
path='path_to_downloaded_attachment'
obj = somemodel.objects.create(param1=value, param2=value, somefield=path, param3=value)
obj.save()
Is django expecting any arguments other than path?
You can pass a lambda to upload_to: