Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
65 views

Django Interview Question

Django is called a loosely coupled framework because its MTV architecture completely separates server code from client code. In Django, models and views are on the server while only templates return to the client as HTML, CSS, and data. This allows front-end and back-end developers to work independently with little effect on each other when changing code. Middleware in Django operates on requests before views and on responses before templates to handle functions like session management and user authentication.

Uploaded by

shubham joshi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Django Interview Question

Django is called a loosely coupled framework because its MTV architecture completely separates server code from client code. In Django, models and views are on the server while only templates return to the client as HTML, CSS, and data. This allows front-end and back-end developers to work independently with little effect on each other when changing code. Middleware in Django operates on requests before views and on responses before templates to handle functions like session management and user authentication.

Uploaded by

shubham joshi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q.9 Why is Django called a loosely coupled framework?

Ans. Django is called a loosely coupled framework because of the MTV


architecture it’s based on.
Django’s architecture is a variant of MVC architecture and MTV is useful
because it completely separates server code from the client’s machine.

Django’s Models and Views are present on the client machine and only
templates return to the client, which are essentially HTML, CSS code and
contains the required data from the models.

These components are totally different from each other and therefore,
front-end developers and backend developers can work simultaneously on
the project as these two parts changing will have little to no effect on each
other when changed.

Therefore, Django is a loosely coupled framework.

Q.10 What is Django Rest Framework (DRF)?


Ans. Django REST is a framework which lets you create RESTful APIs
rapidly.
This framework has got funding by many big organizations and is popular
because of its features over Django frameworks like Serialisation,
Authentication policies and Web-browsable API.

RESTful APIs are perfect for web applications since they use low bandwidth
and are designed such that they work well with communications over the
Internet like GET, POST, PUT, etc.

Q.11 Explain the importance of settings.py file and what data/ settings it
contains.
Ans. When Django server starts, it first looks for settings.py. As the name
settings, it is the main settings file of your web application.
Everything inside your Django project like databases, backend engines,
middlewares, installed applications, main URL configurations, static file
addresses, templating engines, allowed hosts and servers and security key
stores in this file as a list or dictionary.

So, when your Django server starts it executes settings.py file and then
loads particular engines and databases so that when a request is given it
can serve the same quickly.

Q.16 What are View functions? Can we directly import a function in URL?
Ans. The View is the middle component in Django that receives data from
the Django models and pass the same to the Templates.
Every application in Django comes with views.py file, this file contains the
View functions.
The View functions are functions which receive an argument and they
return a browser-renderable format or a redirect.

Django Views function can import directly in the urls file.

For that, we have to first import the view function in the urls.py file and
then add the path/ URL which browser should request to call that View
function.

Here as you can see that we imported all the functions from our View
module which is in the same folder.

We added the URL in the urlpatterns list (red box). When the ‘dataflair/’
gets searched in the yellow box, we have called a function named index.

Q.26 Why is Django better than Flask?


Ans. Django has its own unique qualities over Flask which is also a Python
Framework. The key differences between them are:
 Django is a high-level Python framework while Flask is a low-
level Python Framework providing you with the minimum
functionality, a server would require.
 Django comes with lots of built-in functionality like Django ORM,
Admin Panel, Web-templating System, Inheritance,
serialization while Flask comes with a development server, NoSQL
support, support for unit testing, which are already there in
Django.
 Flask is more customizable than Django as Flask comes with no
pre-defined structure or scaffold while Django’s file structure is
fixed.
 Flask settings are user made and can be altered completely by the
user. Django settings are not customizable to that degree, it has
variables where only values are modifiable.
 Flask has more speed than Django when it comes to processing
requests but that comes without any APIs or functionality which
Django gives you in-built.
 Flask is for the developers who want more flexibility on their
website and don’t need lots of built-in extra functions, while
Django is for developers who want rapid development of their
applications that can sustain dynamic changes to its environment.

Q.28 Middleware in Django is useful for which purpose?


Ans. Middleware in the Django framework is the component that operates
on request and transfers it to the view and before passing it to the template
engine, it starts operating on a response.
This is the list of middleware that installs by default in your Django
framework.

It serves many different purposes like session management, user


authentication, etc.

You might also like