View design for a Django website which has a RESTful API from the get go
|September 6, 2014||Posted by forumadmin under TechQns||
I am trying to build a Django powered website. I want the website to be dynamic. For example, I want the profile page for a authenticated user to contain multiple resources (like a friends list, a group list, usage history etc) and these resources should be loaded in the same area on the page by making API calls without reloading the page.
Here is my understanding of the process:
- Browser on the client side requests the profile page at www.example.com/user:id
- The API returns a JSON response which contain the data requested.
I thought that in order to do this, some of my server side views need to be ordinary Django views which returns an HTTP response, while some others need to be API views which return JSON.
Now here’s my confusion. Let’s say www.example.com/user:id is processed using an ordinary django view, while www.example.com/user/:id/friendslist is processed using an API view. Now if the user inadvertently points the browser at www.example.com/user/:id/friendslist by typing the entire URL and hits go, what happens?
I am just a beginner and I am sure I got the flow of logic wrong. Can someone please point out which part I got wrong?
|Asked By – Dibya Chakravorty||Read Answers|