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

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.

Related

Confused about API relevance and 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 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

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.

Django or Flask or Falcon for Microservices [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 7 years ago.
Improve this question
Why is Microservice Architecture better than monolithic architecture? I know the answer will be because the microservice architecture is more scalable and each service is independent of each other etc.
My following question is: should we build using Flask or Django REST Framework?
I have also heard of a framework know as Falcon as per there documentation seems good enough.
Microservices is an architecture, not a web* framework choice
I don't think whether your app turns out to be a monolith or a microservice depends on the web framework that you are using (e.g. Django or Flask)
*Unless we're talking about frameworks specifically built to deal with managing microservices (e.g. to facilitate service discovery) web frameworks like Django or Flask are pretty equivalent (input HTTP request, output HTTP response)
Maybe their perceived popularity in a given use case (e.g. Django monolith or Flask microservice) may suggest they are better suited for a particular deployment style, but you could a microservice with Django just as easily as you can a monolith with Flask.
For instance, if I select Flask as my web framework, and in a single Flask app/process I implement all of the services (auth, admin, reporting, payroll, marketing, billing, messaging, search etc), where everything communicates on the code level, then I'd end up with a monolith.
On the other hand, if for instance I take Django, and divide my services into several small Django deploys, and make it so they only communicate through well defined HTTP contracts, and can be updated/deployed independently, then I'd end up with a microservice.
Bottom line is, a microservice is more than just the web framework you use, so use whichever one you like the most, until you have more specific requirements and e.g. 3rd party libs that are useful to you and are only available for a given framework but not the other.

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