Hello everyone,
I am working on a Django project where I need to upload a file via the Django admin interface, process it using a specific class, and then store the processed data in different models based on the file’s content. The key requirement is that the file itself should not be saved in the database or the file system after it is uploaded.
Here’s a summary of what I need:
- Upload a file (KML format) via Django Admin: I want to create a file upload field in the admin that allows users to upload a KML file.
2.Process the file using a custom class: After the file is uploaded, it should be immediately processed by a class I’ve written (KmlLicense), which extracts geometrical data from the KML file.
-
Store processed data in other models: The extracted data (points, lines, polygons) should be stored in different models (LicensePoint, LicenseLine, LicensePolygon), depending on the geometry.
-
No need to save the uploaded file: I don’t want the uploaded KML file itself to be saved either in the database or in the media directory of my Django project.
Questions:
How can I set up the Django admin to upload a file, process it with my class, and not save the file itself?
Is there a way to do this entirely within Django Admin without creating a temporary model?
It’s not necessary to provide exact code; a guideline would be enough since I couldn’t find anything related to this use case in the Django documentation.
Any example code or pointers would be greatly appreciated!
Thank you for your help!