I am new to django…
I have a small app up and running that lists objects in a class.
What I want is creating an object when detecting an incoming file in a folder.
I am monitoring the folder with django-watchdog and the script works fine.
Anyone has an idea?
Thank you in advance…
If you make an API in your Django app then when the script detects the file, it could call the API to tell Django the file exists?
Actually the script is running at the same place. I would like to populate my class with objects when detecting incoming files in a folder.
Actually I am trying to do an intranet app where I could distribute pdfs and related info to different people/login in order they can process it. The pdfs could come from various places, but one of is a scanner. I thought about scanning into a django static folder and create instance of a IncomingFile Class when a new file would be detected.
Then I can list the IncomingFiles.objects in a table and process them for distribution among users.
When you say the script is running at the same place, do you mean that the script and the Django app are running on the same computer? Having Django and the script interact over an API still makes sense in that case I think, I don’t see why it wouldn’t?
You could also run the script as a Django management command. So you would run it using
python manage.py scanforfiles or whatever. Then you can directly add models instead of calling an API, just like you would in any other Django code.
Thanks, I will try your second version and keep you informed.
Using an API makes sense certainly but it’s my first django / web app in general so it would just add more complexity on top of things that I don’t master
Id also suggest not using statcfiles for these files - Django has file upload handling so I’d suggest trying to use that instead.
I think that’s what I am doing in a subfolder of the /MEDIA folder…
By static, I meant that the folder is never gonna change.
Up and running!!! Thanks a lot