I need to call external REST APIs from Django. External data source schemas resemble my Django models. I have to keep synchronized remote and local data (maybe not relevant for the question)
Questions:
- What is the most logical place to call external web services: from a model method or from a view?
- Should I put the code that calls the remote API into external modules that will then be called by the views?
- Is it possible to conditionally select a data source? The value of representing data from the REST API or local models depending on their "freshness"?
thanks
EDIT: for people who want to close this question: from the very beginning I posed the question in three simple questions, and so far I have received good answers, thanks.
python rest django django-models django-views
Leonardo
source share