is Django 'app' equal to 'component' in Angular? - django

Just started learning Django, as an Angular developer can we say that apps in Django are similar to Angular components ?

I don't think it's, for example we don't need create a component for a navbar or a dashboard. App it's like parts of your application, for example, you have a main app which gonna handle the general stuff and you can have a clients app to handle clients stuff, etc.
Creating apps your application gets more organized and more structured

Yes it is. It's the way of modularizing your code according to the functionality.

Related

Hosting a ember application under angular Progressive web apps

We need to create a PWA with angular which will wrap the ember application and communicate through some navigation and events.
PWa will be just as a container which hosts the ember so that the application can be used as native and as webapps through every devices.
We need some approaches to get some solution regarding the above requirement.
Will it be possible for everyone to give some light one that.
Planning to host the application using iframe under PWA and communicate.Not sure whether it will be helpful or not.
It's not the best idea to use Angular to create a PWA for an Ember app, you should be doing this in Ember.
One reason that it might not be the greatest idea is that if you're adding Angular to your setup you are adding a minimum of 130KB of compressed JS before taking into account any features that you might be using. Assuming a baseline Ember app size you're talking about adding a roughly 60% extra JS to achieve something that can also be achieved by Ember.
It sounds like you might be following a tutorial on how to turn an app into a PWA that is based on Angular. If you are you having specific issues that you don't know how to solve with Ember I would recommend joining the Ember Community Discord and asking for some help there and maybe someone will point you in the right direction.

Django + Vue with multiple apps

There are plenty of tutorials and helpful posts how to use Django and Vue properly (in various options) all over the Internet.
But I didn't find a single one who describes how to create a Django application which consists of more than one app, each having it's own part of the Vue frontend.
I am creating a Django application with a Vue frontend, and it will have a lot of apps that can be plugged into the main system very easily (using a custom framework). But this only is the backend. I'd like to enable each Django app for having a "plugin" part of the frontend as well: e.g. a set of Vue components that are rendered "dynamically" in the frontend when this app is added in INSTALLED_APPS.
How can I provide "plugin hooks" in Vue to load those components? All the things I have seen (dynamic/lazy component loading with webpack using webpack-loader, etc.) is not what I want. It only describes how to load a component that is predefined later in the http request timeline.
How am I supposed to "merge" all the components? Can I simply create components in static folders and let ./manage.py collectstatic do the magic?
It doesn't matter if the application is a SPA or maybe I have to use Django templates (with Vue components included) - both would be a viable method.
Maybe this even is a webpack question and should be: How do I bring Vue (or React, etc) to collect its sources from different subdirectories like foo_app/static/, blah_app/static/, bar_app/static - is there a way to tell Vue/Webpack/etc to search in myproject/*/static for Vue components to merge?
And can I include "all components" (dynamical amount) than in another component, which is needed for such a system?
Can anyone enlighten me here - is that completely impossible? Or am I thinking in the wrong direction?
Thanks.
I have a couple of VueJS apps in my django site and I'm planning to add more.
I bundle them with webpack with the help of django-webpack-loader.
https://github.com/owais/django-webpack-loader

Is Ember really a single page app?

I have been studying Ember.js for about a week now and all examples I studied were single page apps. I have been told to work on a project which expands more than 30 pages and I have no idea what the directory structure would be and if Ember is the best tool as I have never seen an application that links to other pages in the project?
Yes, ember is a single page application, since you only go to one page, it loads the app then you don't need to fetch anymore pages from the server the ember app handles everything. For bigger apps like the one you're suggesting, you'd put each object type (models, controllers, routes, templates, views, etc...) into their own directory for organization.
I quite like to use Ember JS for SPA due to it's flexibility but when it comes to browser support, then I've no choice but to go for Knockout JS for implementing a SPA!
They are both great for SPA, Ember has lot more to offer, but for those that must still support IE7 then the best choice would be Knockout JS...
Hope it helps :)

using backbone/ember makes django being a simple REST API?

I have read a couple of articles about using new JS frameworks like Backbone.js or Ember.js
I have come up to this statement:
If I use a JS framework like Backbone.js/Ember.js, I then move the logic from the back-end (Django) to the front-end.
Therefore, will Django actually be used only for its Models?
Does that mean that Django Views and Django Template are not needed anymore and the Django back-end is kinda turn into a "basic" REST API that will be consumed by the front end.
Do you agree? Is it then the purpose of Django in this case?
Is turning the django backend into a REST API one of the most suitable use case when using a framework like Backbone.js/Ember.js for the front-end?
Thanks.
Django is perfectly fine to be used this way, you still get the admin, the models, the orm and all the third-party plugins. However, it isn't blazingly fast, so if you're doing simple document level, non-relational REST mapping, you might wan't to look into node.js and mongoDB for instance.
If you're sticking with django (like we are, we like the structure it gives us), you can use one of the REST plugins:
Django Rest Framework A perfect match since DRF 2.0, under very active development!
Django Tastypie (checkout backbone-tastypie.js for integration)
Django Piston (might be a bit stale or has development picked up lately?)
If you only want to work with frontend development, checkout the Backend-as-a-Service places like cloudmine.me or firebase.com that handle all backend stuff for you, for a price of course.
Django may seem unnecessary once you start thinking about single page solutions and Javascript applications, but if you want your site to be 'fail proof' it wouldn't be impossible to develop both a client side Javascript version of the site as well as a backend django side incase the user, or your site's javascript, fails at some level. Of course this requires creating your site twice, and probably isn't needed in the age of modern browsers, but such would be one of the few instances where you would mix the two for a complete solution.
Yes, that's about it. You can use it to manage authentication to resources and such and maybe use a main view for your application but you won't need to use the server side templating since these frameworks are made to work with json/xml response.
That's why a lot of people are moving to lighter backend/backbone or ember combo instead of a complete solution like django. You can also use your django for caching json response which makes your application appears faster.
We are doing that and use django-piston to make it easier on you.
Normally you make your entire website under Django and only one page will be a "single app page" using backbone.js, usually that page is a very interactive page, with lots of small updates that occur frequently and need to be shown very fast to the user. This page, because of the large number of changes and user interactions is constructed on the client-side so that you are using his PC resources and not the server's, the rest of the pages can use django because it offers you a very stable and secure framework for the server-side

Django app as REST-based service

According to the documentation, an app is a module which deals a well defined operation.
Is it correct to think about an app as a REST-based service? or is it mandatory to use some framework like piston or tastypie to create a RESTful web service around an app?
Generally, no. Django app is really just a python module, with some interfaces to django internals like models, urls, admin discovery etc.
To implement REST, you still have to manage network communications via views, and this is where you either write your own code or use the help of tastypie/piston/etc.
Please do have a look at django-rest-framework, I just stepped over from tastypie to this new framework, works great!
http://django-rest-framework.org/
Especially the class based views and the browsable api! and may other advantages (e..g. to upload images)
And to answer your question:
The rest-base service is an extra entry to your webapp.
I made some api's for some projects using the django-rest-framework, most project members were surprised they got a webapp as an extra, while it was actually the other way around. You make a django app (with views models and urls) and on top off that you make the api.