Django interview questions

python django

1) What do you understand by Django?

Django is a free and open-source web application framework, written in Python. Django is named after Django Reinhardt, a Jazz guitarist from the 1930s to early 1950s who is one of the best guitarists of all time. Django was mainly developed to handle the intensive design of the newsroom. You can even build high-quality web applications using this. It adheres to the DRY principle and focuses completely on automating as much as possible.

2) What does Of Django Field Class types do?

Following points are specified by the Django Field Class type: –

  • It specifies the database column type.
  • It also specifies the default HTML widget which is availed while we render the form field.
  • The requirements of the minimal validation which is used in Django admin is also specified by the field class.

3) Does Django Follow Architectural pattern?

Yes, Django follows Model-View-Controller (MVC) architectural pattern.

4) Clarify the architecture of Django?

Django follows MVC -MVT architecture. MVT stands for Model View Template design Pattern which is a little bit different from MVC (Model View Controller ) Pattern.

5) Is Django stable or not?

Of course, Django is stable. Most of the companies are using it.

6) Is Django a high level or low-level framework?

Django is a high-level Python’s web framework which was designed for rapid development and clean realistic design.

7) How does Django work?

Django can be broken into several components:

  • Models.py file: This file defines your data model by extending your single code line into full database tables and add a pre-built administration section to manage content.
  • Urls.py file: It uses a habitual expression to confine URL patterns for processing.
  • Views.py file: It is the main part of Django. The actual processing happens in view.

8) What is the name of the Foundation which manages Django web framework?

Django web framework is managed and maintained by an independent and non-profit organization named Django Software Foundation (DSF).

9) Name the features available in Django web framework?

Features available in Django web framework are:

  • Admin Interface (CRUD)
  • Templating
  • Form handling
  • Internationalization
  • Session, user management, role-based permissions
  • Object-relational mapping (ORM)
  • Testing Framework
  • Fantastic Documentation

10) What are the advantages of using Django for web development?

  • Auto-generated web admin is provided by Django to make website administration easy.
  • Pre-packaged API is also available for common user tasks.
  • Business logic can be separated from the HTML using this framework.
  • You can even divide the code modules into logical groups so as to make it flexible for changing.
  • Template system is being provided so as to define HTML template for your web page to avoid code duplication.

11) What is the process of creating a project in Django?

To start a project in Django, use the command $django-admin.py and then use the following command:Project

_init_.py

manage.py

settings.py

urls.py

12) Is Django a content management system (CMS)?

No, Django is not a Content Management System (CMS). Instead, it is a Web framework and a programming tool that helps you in building elegant websites.

13) What does the Django templates contain?

A template is a simple text file. It can create any text-based format like XML, CSV, HTML, etc. A template contains variables that get replaced with values when the template is evaluated and tags (%tag%) that control the logic of the template.

14) What is the use of session framework in Django?

The session framework helps you in storing and retrieving arbitrary data on a per-site visitor basis. The data is stored on the server side and abstracts the receiving and sending of cookies. We can implement sessions through a piece of middleware.

15) How can you set up static files in Django?

Basically, we require three main things to set up static files in Django:

1) Set STATIC_ROOT in settings.py

2) Run manage.py collect static

3) Set up a Static Files entry on the PythonAnywhere web tab

16) How to use file based sessions?

You have to set the SESSION_ENGINE settings to “django.contrib.sessions.backends.file” to use file-based session.

17) What is some typical usage of middlewares in Django?

Middleware is a function that acts on or transforms a request/response before/after it passes through the view layer (e.g. adding the user object to the request)
Some usage of middlewares in Django is:

  • It can be used for Session management,
  • User authentication can be done with the help of this.
  • It helps in Cross-site request forgery protection
  • Content Gzipping, etc.

18) What is the usage of Django-admin.py and manage.py?

Django-admin.py: It is a Django’s command line utility for administrative tasks.

Manage.py: It is an automatically created file in each Django project. It is a thin wrapper around the Django-admin.py.

It has the following usage:

  • It puts your project’s package on sys.path.
  • It sets the DJANGO_SETTING_MODULE environment variable to points to your project’s setting.py file.

19) What are signals in Django ?

Signal are inbuilt utility in Django. They allow to execute some piece of code based on some action or event is occurred in framework something like a new user register, on delete of a record.
Below is the list of some inbuilt signal in Django.

  • pre_save and post_save.
  • pre_delete and post_delete
  • pre_request and post_request
  • pre_request and post_request

20) Is Django free?

Yes, Django is free open source web framework for Python

21) What are features of Django ?

Django’s features are: Rapid Development, Secure, Scalable, Fully Loaded, Versatile, Open Source, Vast and Supported Community.

22) What id CRUD ?

CRUD means Create, Read, Update and Delete. It provides a memorable framework for reminding developers of how to construct full, usable models when building application programming interfaces (APIs).

23) Explain the architecture of Django?

Django architecture consists of:
Models: It describes your database schema and your data structure
Views: It controls what a user sees, the view retrieves data from appropriate models and execute any calculation made to the data and pass it to the template
Templates: It determines how the user sees it. It describes how the data received from the views should be changed or formatted for display on the page
Controller: It is the heart of the system. It handles requests and responses, setting up database connections and loading add-ons and specifies the Django framework and URL parsing.

24) Why should Django be used for web development?

Django should be used for web development because of the following reasons:

  • It allows dividing the code module into logical groups to make it flexible to change.
  • To easy the website administration, it provides an auto-generated web admin module.
  • It provides pre-packaged API for common user tasks.
  • It enables us to define what should be URL for a given function.
  • It enables to separate business logic from the HTML.
  • Everything is written in Python programming language.
  • It gives you template system to define HTML template for your web page to avoid code duplication.

    Leave a Reply

    Your email address will not be published. Required fields are marked *