Django Interview Questions & Answers

  1. Question 1. What Is Django?

    Answer :

    Django is a high­level Python Web framework that encourages rapid development and clean, pragmatic design. Developed by a fast­moving online­news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high­performing, elegant Web applications quickly. 

  2. Question 2. What Does Django Mean?

    Answer :

    Django is named after Django Reinhardt, a gypsy jazz guitarist from the 1930s to early 1950s who is known as one of the best guitarists of all time.

  3. Python Interview Questions

  4. Question 3. Which Architectural Pattern Does Django Follow?

    Answer :

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

  5. Question 4. Mention What Does The Django Templates Consists Of?

    Answer :

    The 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 controls the logic of the template.

  6. Python Tutorial

  7. Question 5. Which Foundation Manages Django Web Framework?

    Answer :

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

  8. Java Script Interview Questions

  9. Question 6. Is Django Stable?

    Answer :

    Yes, Django is quite stable. Many companies like Disqus, Instagram, Pinterest, and Mozilla have been using Django for many years.

  10. Question 7. What Are The Features Available In Django Web Framework?

    Answer :

    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
  11. Java Script Tutorial
    PHP Interview Questions

  12. Question 8. What Are The Advantages Of Using Django For Web Development?

    Answer :

    • It facilitates you to divide code modules into logical groups to make it flexible to change.
    • It provides auto-generated web admin to make website administration easy.
    • It provides pre-packaged API for common user tasks.
    • It provides template system to define HTML template for your web page to avoid code duplication.
    • It enables you to define what URL is for a given function.
    • It enables you to separate business logic from the HTML.
  13. Question 9. How To Create A Project In Django?

    Answer :

    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

  14. HTML+Javascript Interview Questions

  15. Question 10. How Can You Set Up The Database In Djanago?

    Answer :

    To set up a database in Django, you can use the command edit mysite/setting.py , it is a normal python module with module level representing Django settings.
    By default, Django uses SQLite database. It is easy for Django users because it doesn’t require any other type of installation. In the case of other database you have to the following keys in the DATABASE ‘default’ item to match your database connection settings.
    Engines: you can change database by using ‘django.db.backends.sqlite3’ , ‘django.db.backeneds.mysql’, ‘django.db.backends.postgresql_psycopg2’, ‘django.db.backends.oracle’ and so on
    Name: The name of your database. In the case if you are using SQLite as your database, in that case database will be a file on your computer, Name should be a full absolute path, including file name of that file.
    Note: You have to add setting likes setting like Password, Host, User, etc. in your database, if you are not choosing SQLite as your database.

  16. PHP Tutorial

  17. Question 11. What Does The Django Templates Contain?

    Answer :

    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 controls the logic of the template.

  18. Ruby on Rails Interview Questions

  19. Question 12. Is Django A Content Management System (cms)?

    Answer :

    No, Django is not a CMS. Instead, it is a Web framework and a programming tool that makes you able to build websites.

  20. Python Interview Questions

  21. Question 13. What Is The Use Of Session Framework In Django?

    Answer :

    The session framework facilitates you to store and retrieve arbitrary data on a per-site visitor basis. It stores data on the server side and abstracts the receiving and sending of cookies. Session can be implemented through a piece of middleware.

  22. Ruby on Rails Tutorial

  23. Question 14. How Can You Set Up Static Files In Django?

    Answer :

    There are three main things required to set up static files in Django:
    1.Set STATIC_ROOT in settings.py
    2.run manage.py collectsatic
    3.set up a Static Files entry on the PythonAnywhere web tab

  24. Question 15. How To Use File Based Sessions?

    Answer :

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

  25. Ruby Interview Questions

  26. Question 16. What Is Some Typical Usage Of Middlewares In Django?

    Answer :

    Some usage of middlewares in Django is:

    • Session management
    • Use authentication
    • Cross-site request forgery protection
    • Content Gzipping, etc.
  27. JavaServer Faces (JSF) Tutorial

  28. Question 17. What Does Of Django Field Class Types Do?

    Answer :

    The Django field class types specify:

    • The database column type.
    • The default HTML widget to avail while rendering a form field.
    • The minimal validation requirements used in Django admin.
    • Automatic generated forms.
  29. JavaServer Faces (JSF) Interview Questions

  30. Question 18. What Constitutes Django Templates?

    Answer :

    Template can create formats like XML,HTML and CSV(which are text based formats). In general terms template is a simple text file. It is made up of variables that will later be replaced by values after the template is evaluated and has tags which will control template’s logic.

  31. Java Script Interview Questions

  32. Question 19. How Do You Use Views In Django?

    Answer :

    Views will take request to return response.  Let’s write a view in Django :  “example” using template example.html , using  the date-time module to tell us exact time of reloading the page.  Let’s edit a file called view.py, and it will be inside randomsite/randomapp/
    To do this save and copy following into a file:

    from datatime import datetime
          from django.shortcuts import render
         def home (request):
    return render(request, ‘Guru99_home.html’, {‘right_now’: datetime.utcnow()})
    You have to determine the  VIEW first, and then uncomment this line located in file urls.py
    # url ( r ‘^$’ , ‘randomsite.randomapp.views.home’ , name ‘example’),
    This will reload the site making changes obvious.

  33. Javascript Objects Tutorial

  34. Question 20. What Makes Up Django Architecture?

    Answer :

    Django runs on MVC architecture. Following are the components that make up django architecture:
    Models: Models elaborate back-end stuffs like database schema.(relationships)
    Views: Views control what is to be shown to end-user.
    Templates: Templates deal with formatting of view.
    Controller: Takes entire control of Models.A MVC framework can be compared to a Cable TV with remote. A Television set is View(that interacts with end user), cable provider is model(that works in back-end) and Controller is remote that controls which channel to select and display it through view.

  35. Javascript Objects Interview Questions

  36. Question 21. What Does Session Framework Do In Django Framework?

    Answer :

    Session framework in django will store data on server side and interact with end-users. Session is generally used with a middle-ware. It also helps in receiving and sending cookies for authentication of a user.

  37. Question 22. Mention Caching Strategies That You Know In Django?

    Answer :

    Few caching strategies that are available in Django are as follows:

    • File sytem caching
    • In-memory caching
    • Using Memcached
    • Database caching
  38. Javascript Advanced Tutorial

  39. Question 23. Why Django Should Be Used For Web-development?

    Answer :

    • It allows you to divide code modules into logical groups to make it flexible to change
    • To ease the website administration, it provides auto-generated web admin
    • It provides pre-packaged API for common user tasks
    • It gives you template system to define HTML template for your web page to avoid code duplication
    • It enables you to define what URL be for a given function
    • It enables you to separate business logic from the HTML
    • Everything is in python
  40. Javascript Advanced Interview Questions

  41. Question 24. What Do You Think Are Limitation Of Django Object Relation Mapping(orm)?

    Answer :

    If the data is complex and consists of multiple joins using the SQL  will be clearer.
    If Performance is a concern for your, ORM aren’t your choice. Genrally. Object-relation-mapping are considered good option to construct an optimized query, SQL has an upper hand when compared to ORM.

  42. PHP Interview Questions

  43. Question 25. Mention What Does The Django Field Class Types?

    Answer :

    Field class types determines:

    • The database column type
    • The default HTML widget to avail while rendering a form field
    • The minimal validation requirements used in Django admin and in automatically generated forms
  44. Ruby on Rails 2.1 Tutorial

  45. Question 26. List Out The Inheritance Styles In Django?

    Answer :

    In Django, there is three possible inheritance styles

    1. Abstract base classes: This style is used when you only wants parent’s class to hold information that you don’t want to type out for each child model
    2. Multi-table Inheritance: This style is used If you are sub-classing an existing model and need each model to have its own database table
    3. Proxy models: You can use this model, If you only want to modify the Python level behavior of the model, without changing the model’s fields
  46. XHTML Interview Questions

  47. Question 27. Mention What Command Line Can Be Used To Load Data Into Django?

    Answer :

    To load data into Django you have to use the command line Django-admin.py loaddata. The command line will searches the data and loads the contents of the named fixtures into the database.

  48. HTML+Javascript Interview Questions

  49. Question 28. Explain What Does Django-admin.py Make Messages Command Is Used For?

    Answer :

    This command line executes over the entire source tree of the current directory and abstracts all the strings marked for translation.  It makes a message file in the locale directory.

  50. XHTML Tutorial

  51. Question 29. Explain The Use Of Session Framework In Django?

    Answer :

    In Django, the session framework enables you to store and retrieve arbitrary data on a per-site-visitor basis.  It stores data on the server side and abstracts the receiving and sending of cookies.  Session can be implemented through a piece of middleware.

  52. Apache Solr Interview Questions

  53. Question 30. Explain How You Can Use File Based Sessions?

    Answer :

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

  54. Question 31. Explain The Migration In Django And How You Can Do In Sql?

    Answer :

    Migration in Django is to make changes to your models like deleting a model, adding a field, etc. into your database schema.  There are several commands you use to interact with migrations.

    • Migrate
    • Makemigrations
    • Sqlmigrate

    To do the migration in SQL, you have to print the SQL statement for resetting sequences for a given app name.
    django-admin.py sqlsequencreset
    Use this command to generate SQL that will fix cases where a sequence is out sync with its automatically incremented field data.

  55. Apache Solr Tutorial