I managed to create files using directory path, something like
imports
def createFile (self, my_data, nameFile):
directory = "./my_app/folder/" + nameFile + ".txt" # PATH directory
my_File = open (directory, "w")
my_File.write (my_data)
my_File.close ()
return true
In itself the important thing is import os and write well the directory where the file will be created. No need to modify anything else.
In the Django documentation I saw something in the import of some classes but in my case this was enough, on the other hand now that I write this answer from django.core.files import File which as seen is the equivalent of import os
I tried to use these
from django.core.files.base import ContentFile
from django.core.files.storage import default_storage
from django.core.files.storage import FileSystemStorage
As I do not have time and I had problems with these, I went with the easy
PS: maybe then use from django.core.files import File instead of import os as it seems to be the same, if so I update the answer.