Django interview questions

Django quiz questions

  • 1.

    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.
    View
  • 2.

    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.
    View
  • 3.

    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.

    View
  • 4.

    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

    View
  • 5.

    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.

    View
  • 6.

    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.

    View
  • 7.

    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.

    View
  • 8.

    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.

    View
  • 9.

    What are the inheritance styles in Django?

    Answer:

    There are three possible inheritance styles in Django:

    1. Abstract base classes: This style is used when you only want 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: This style is used, if you only want to modify the Python level behavior of the model, without changing the model's fields.

    View
  • 10.

    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

    View
  • 11.

    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.
    View
  • 12.

    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
    View
  • 13.

    Is Django stable?

    Answer:

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

    View
  • 14.

    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).

    View
  • 15.

    Explain the architecture of Django?

    Answer:

    Django is based on MVC architecture. It contains the following layers:

    Models: It describes the database schema and data structure.

    Views: The view layer is a user interface. 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: Controller is the heart of the system. It handles requests and responses, setting up database connections and loading add-ons. It specifies the Django framework and URL parsing.

    View
  • 16.

    Which architectural pattern does Django Follow?

    Answer:

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

    View
  • 17.

    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.

    View
  • 18.

    What is Django?

    Answer:

    Django is a free and open source web application framework, written in Python.

    View
  • 19.

    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
    View
  • 20.

    Explain what does django-admin.py makemessages 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.

    View

© 2017 QuizBucket.org