Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to run Python Code in Django once the file is uploaded?

Tags:

python

django

My django application has a file uploader which uploads to a specific location in my local system. It redirects to a new html page which shows successful message after upload is done. Once the file is uploaded I need to do some processing of csv files. I have a python code which does the processing.

Now my question is, where do I put the python file in the django project and how do i call it to be run once the upload is done?

Any help is appreciable Thanks in advance

like image 557
Sampath Kumar Avatar asked Mar 16 '26 02:03

Sampath Kumar


1 Answers

You can place it anywhere you like, it's just Python. Maybe in a csv_processing.py if it fits in a single module, or as a completely independent library if it's more. Django doesn't have an opinion on this.

The best way to run it is by doing it asynchronously using Celery.

like image 183
RemcoGerlich Avatar answered Mar 18 '26 16:03

RemcoGerlich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!