0

I'm looking for some advice on "best practice" when writing a web app that exposes data via an API as well as human-readable pages. The question is platform-neutral, but I'm looking at this from the perspective of a Django site.

I've been watching the "30 Days to Learn jQuery" tutorials at tutsplus.com, and just saw the video where they retrieve JSON data from the Twitter API and render it on the page. Now, currently, I would build views that access the Django models and pass some data to the template, which is rendered for the user. However, this got me thinking -- if I've already got a JSON API using tastypie, why not write Javascript in my template to read the data from there?

So, can anyone tell me why I should or should not take this approach?

1 Answer 1

2

There is going to be some sort of performance overhead. If each request requires you to consume an API that you are the owner of, there are things like authentication that become unnecessary. In some cases it is an unnecessary layer of abstraction.

Additionally, I think that it is easier/cleaner to develop templates based around django objects than having to consume the Javascript and manipulate it via jquery.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.