Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to externally populate a Django model?

What is the best idea to fill up data into a Django model from an external source?

E.g. I have a model Run, and runs data in an XML file, which changes weekly.

Should I create a view and call that view URL from a curl cronjob (with the advantage that that data can be read anytime, not only when the cronjob runs), or create a python script and install that script as a cron (with DJANGO _SETTINGS _MODULE variable setup before executing the script)?

like image 696
Marius Avatar asked Feb 07 '09 17:02

Marius


1 Answers

There is excellent way to do some maintenance-like jobs in project environment- write a custom manage.py command. It takes all environment configuration and other stuff allows you to concentrate on concrete task.

And of course call it directly by cron.

like image 146
Alex Koshelev Avatar answered Oct 19 '22 11:10

Alex Koshelev