Confused about API relevance and Django [closed] - django

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Im new to web development and trying to learn APIs through Django Rest Framework. I am actually confused about why we actually need to build an API. For example, I've seen tutorials of creating blog APIs, where it returns the posts and its info. Why would we need an API for that? We can simply create regular Django views to do the same. I've heard that APIs only provide the 'data', but I can also obtain data from regular Django. So why would you install a totally new 'sub' framework to do these for you?

Suppose you want to build a mobile application that serves some blog posts. have you thought about how you are going to fetch the blog posts from a back-end.
Take the case of instagram, the app fetches images,comments and tags from the django backend in the form of json data and can display relevant data on the application. in short, APIs can be used when the backend and frontend technologies are different and they can communicate through APIs

The biggest reason to use Django REST Framework is because it makes serialization so easy!
see this medium post
https://medium.com/#BennettGarner/build-your-first-rest-api-with-django-rest-framework-e394e39a482c

Related

Do I really need Django Rest Framework to develop Restful api with Django? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I am learning Django to develop api, but I find that most of the tutorials on the web are all use Django Rest Framework. Does it really need this framework to develop restful apis? Can I develop restful apis without Django Rest Framework
Of course you can develop a rest API without DRF - a rest API is just a set of urls mapped to views that take HTTP requests and return HTTP responses, period. Now since most often "rest API" implies JSON as the default input and output format and a proper use of HTTP verbs, some specific kind of auth etc there are some repetitive tasks that can be factored out - either rolling your own mini-framework, using an existing lightweight one like restless, or trying to find your way in the 800-pound gorilla DRF.
Of course, you can but why, when Django Rest Framework does the work for you ? If you wanna learn how it's working just use Django Rest Framework and watch the sources code of it.
Surely you can develop REST API with django, Django Rest Framework isn't part of Django project its a third party tool which facilitate faster API development. DRF takes care of lot of stuff which you need to take care by your own otherwise like.
Handling token
Authorization
Authentication
Serialization & Deserialization of dataobject
likewise many other.

How Django ORM, REST API and a Web app stack up? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to develop a web application in Django including a REST API and also a web application to allow user to login and see stuff. I'm a bit confused as to how these are connected together.
I'm thinking that Django ORM is at the bottom and on top of that comes the API and then the web app uses the API to generate HTML. Is this correct understanding? A yes or no with few {key}words explanation would be enough.
What is the best practice?
Basically Django ORM is the bottom layer in your app as it will make possible to manipulate your data. When it comes to APIs, the main goal is to make accessible and manipulable your data from different devices (clients), for instance your web app and your iOS app may consume the same API and that will reduce your implementation time and eventually it will give you a better integration through your different clients and devices. Last but not least, the Web app is at this point the consumer to your API and your front-end.
You could check Tastypie or Django REST framework/ in order to implement your API and for your web app you have plenty of frameworks that you could use as Backbone, AngularJS etc.

What to use for a backend setup while working with AngularJS in client-side? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I need to build a backend for a web application, i'm using AngularJS in the client-side, but i'm lost in what to use to accomplish the backend stuff as well as the web service.
I've read about Breezejs but it requires .Net, i know php btw (yii), and i need this backend to accept and return JSON. It will be used to store users info and do crud operations.
This is a subjective question, not very suitable for StackOverflow...
...but I must recommend Laravel 4, since you are used to PHP.
If the INPUT is JSON, the framework delivers it to you easily:
$value = Input::get('key');
If you are returning a model, its toArray method is applied automatically:
return $this->user->configuration;
The code snippet above is actually a real single-liner controller method I have in my app. The user is already logged in... there is a "configuration" table (one-to-one relationship)... With the above line, Eloquent (Laravel ORM) will make the proper query, fetch the result, and return the record... and it will be transformed into JSON for delivery...
I am used to several PHP frameworks, from Code Igniter to Symfony 2 - and I've never been happier than now with Laravel 4.
Yii is a normal solution since you already know some PHP, so this is the easy way.
Another way is if you want some exotic, I'll recommend CompoundJS framework for node.js, its good for REST API.

Single Page Application or Multi-page Application? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am working on a web application project. This web application will have many users, and each user will be able to upload images to the website. Then I will write an android application to access those images. This is the description of my project.
Should I go with single page application such as backbone.js or should i go with a multi-page application approach such as Django? For the database stuff, I was thinking of going with Mongodb for now. Any advice on that is very appreciated !
Thanks,
An SPA (single page app) has nothing to do with going with Django or Backbone. You can write an SPA while using Django. BUT you can also use Backbone along with Django. For more on this, read these posts:
http://sidazad.tumblr.com/post/52201957429/web-2-0-the-switch-to-client-javascript-frameworks
http://sidazad.tumblr.com/post/52591790157/the-search-for-the-perfect-software-stack-part-1
To answer your question, I'd say use Backbone + Django and go with a Single Page App. That's where the web is moving. By using Backbone as well as Django you will get the advantages that Django provides on the server side while getting the great client side code organization and plumbing for a SPA from Backbone.
There are ways in which you can write your django templates so they are reusable on the client side. Look at this project in my GitHub for help with this on which I will be writing a post soon:
https://github.com/sidazad/django-backbone-stack-1

Documenting ServiceStack web services [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
What are the options for documenting a ServiceStack bases web services and I'm not talking about a one line string.
I would like to be able to document, in detail (which can be long), return types, possible HTTP responses, add detailed examples etc.
Is there any support for this in ServiceStack (I couldn't find it)?
If not has anybody solved the problem in some other way.
You can provide metadata descriptions for each of your web services by attributing your Request DTOs with [Api] and [ApiMember] attributes.
This information will be displayed on the dynamic metadata pages.
Another option is to simply create your own dynamic html page, which ServiceStack allows you to do by simply returning a string (containing your html markup). If you go this route you can access the Service Types metadata with the global EndpointHost.ServiceOperations property.
Also if dynamically generating html with C# is not your preference you can also generate html using the built-in Razor Markdown format which makes generating html quite pleasant :)
I realize this question is a couple years old, but there is now Swagger support for ServiceStack API's # https://github.com/ServiceStack/ServiceStack/wiki/Swagger-API