I am new to Django and would like to know that the Django path for adding items to the database is not by entering each field from an html form (as it is done by default), but loading a single file (for example, a json file) to be used to populate the database?
So, let the model have only three fields: name, description, quantity. And I have a text file (myFile.txt) with the inscription "myTitle: myDesc".
I only want a FileField that will accept a text file so that I can load myFile.txt, and the title and description will be read from this file. And at the same time, the quantity will be requested βnormallyβ in the text input, as it would be by default (only the title and description are read from the file).
Of course, a file check will be performed to accept / deny the downloaded file. The problem I am facing is that if I add a FileField to the model, the file will be saved in local storage. I want the contents of the download file to be read, used to create a record in the model, and then deleted.
Even the administrator should not be able to manually add an element that introduces the title and description in the form of HTML, but only by downloading the file. Can someone help me in Django-way?
django django-admin file-upload
Thomas
source share