how can I send a mail with a file saved in a FileField? I don't know how to access the file in the code below.
mail = EmailMessage(subject, message, 'from@from,com', ['firstname.lastname@example.org']) mail.attach(?, ?, 'application/pdf') mail.send()
I tried to open the file with
f = list_pca.pdf_file.open(mode='rb')
where list_pca is an instance of
class ListPCA(models.Model): pdf_file = models.FileField(upload_to=get_file_path_j, null=True, blank=True)
but I get an error "No such file or directory", because the path is wrong.
return the wrong path too. Isn't it supposed to know where is the file thanks to the