InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What are different model inheritance styles in the Django? |
Answer»
|
|
| 2. |
What is the difference between a project and an app in Django? |
|
Answer» In simple WORDS Project is the entire DJANGO APPLICATION and an app is a module inside the project that deals with one SPECIFIC use case. |
|
| 3. |
What are Django URLs? |
|
Answer» URLs are one of the most important parts of a web application and Django provides you with an elegant way to design your own custom URLs with help of its module known as URLconf (URL Configuration). The basic functionality of this python module is to Basic SYNTAX: from django.urls import pathfrom . import viewsurlpatterns = [ path('data/2020/', views.data_2020), path('data/<int:year>/', views.data_year)] |
|
| 4. |
What is Jinja templating? |
|
Answer» Jinja Templating is a very POPULAR templating engine for Python, the latest version is Jinja2. Some of its features are:
|
|
| 5. |
What is django-admin and manage.py and explain its commands? |
|
Answer» django-admin is Django’s command-line utility for administrative TASKS. In addition to this, a manage.py FILE is also automatically created in each Django project. Not only does it perform the same purpose as the django-admin but it also sets the DJANGO_SETTINGS_MODULE environment variable to point to the project's settings.py file.
|
|
| 6. |
What is Django Rest Framework(DRF)? |
|
Answer» Django REST Framework is an open-source framework BASED upon Django which LETS you create RESTFUL APIs rapidly. |
|
| 7. |
Define static files and explain their uses? |
|
Answer» WEBSITES generally need to serve ADDITIONAL files such as IMAGES. JAVASCRIPT or CSS. In Django, these files are referred to as “STATIC files”, Apart from that Django provides django.contrib.staticfiles to manage these static files. |
|
| 8. |
What is Django ORM? |
|
Answer» This ORM (an ACRONYM for Object Relational Mapper) ENABLES us to interact with DATABASES in a more pythonic way like we can avoid writing RAW queries, it is possible to retrieve, save, delete and perform other operations over the database without ever writing any SQL query. It works as an abstraction layer between the models and the database. |
|
| 9. |
What are views in Django? |
|
Answer» A view function, or “view” for short, is SIMPLY a Python function that takes a web REQUEST and returns a web response. This response can be HTML contents of a web PAGE, or a redirect, or a 404 ERROR, or an XML document, or an image, etc. Example: from django.http import HttpResponsedef sample_function(request): return HttpResponse(“Welcome to Django”)There are TWO types of views:
|
|
| 10. |
What are templates in Django or Django template language? |
|
Answer» Templates are an integral PART of the Django MVT architecture. They generally comprise HTML, CSS, and js in which DYNAMIC variables and information are embedded with the help of views. Some constructs are recognized and INTERPRETED by the template engine. The main ones are variables and tags. A template is rendered with a context. Rendering just replaces variables with their VALUES, present in the context, and processes tags. Everything else remains as it is. The syntax of the Django template language includes the following four constructs :
To read more about templates you can refer to this: https://docs.djangoproject.com/en/3.1/topics/templates/ |
|
| 11. |
What are models in Django? |
|
Answer» A model in Django refers to a CLASS that MAPS to a database table or database collection. Each attribute of the Django model class represents a database field. They are defined in app/models.py Example: from django.db import modelsclass SampleModel(models.Model):field1 = models.CharField(max_length = 50)field2 = models.IntegerField()class Meta:db_table = “sample_model”Every model inherits from django.db.models.Model The metaclass helps you set things like available permissions, singular and plural VERSIONS of the name, associated database table name, whether the model is abstract or not, etc. |
|
| 12. |
Explain the django project directory structure? |
Answer»
|
|
| 13. |
Explain Django Architecture? |
|
Answer» Django follows the MVT (Model View Template) pattern which is BASED on the Model View Controller architecture. It’s slightly different from the MVC pattern as it maintains its own conventions, so, the controller is handled by the FRAMEWORK itself. The template is a presentation layer. It is an HTML file mixed with Django Template Language (DTL). The developer PROVIDES the model, the view, and the template then maps it to a URL, and finally, Django serves it to the user. |
|