Django Top Interview Questions 2022
After working with Django for 5+ years and taking numerous interviews, I have realised that the questions one can ask in Django Interview are very limited. I have been on both sides of the table and to be honest, there are just a handful number of questions that one can ask a candidate and one can get to know on how much depth the candidate has worked with Django. Also, the questions might vary a bit depending upon whether you are a fresher or an experienced developer.
In this blog, I would try to list down all the questions which I have come across in all the interview processes and would try to answer them. This blog would be a reference for me, to create separate blogs answering each question on a deeper level. Unfortunately, I am just starting this blog so most of the answers would be added in subsequent months. Also in every question, I shall write that for whom these questions are meant to be as per their experience level they are applying
What does get_or_create
query do in Django?
Experience Level - Beginner
What is the difference between Project and App in Django?
Experience Level - Beginner
- Project is the entire Django code in which you are working. An App is considered to be a module inside the Django project. There can be multiple apps in one single project and generally, people use Django apps for different features, for example, if you are creating a blogging application, then
comments
can be a separate app and along withaccounts
to handle any user management.
What is Django ORM?
Experience Level - Beginner
- ORM stands for Object Relational Mapper which helps users to interact seamlessly with the database without having to worry about the intricacies of SQL. This acts as a bridge between python and the database while making use of all the python syntax and getting the benefits of the database at the same time.
What is the difference between blank=True
and null=True
in model fields?
Experience Level - Beginner/Intermediate
Is Django Signal Synchronous or Asynchronous in nature?
Experience Level - Intermediate/Expert
- Django signals are synchronous in nature, any failure in the chain of signals can cause other signals to fail, unless one uses
send_robust(sender, **kwargs)
instead ofsend(send, **kwargs)
Explain Django ContentType framework.
Experience Level - Expert
Explain GenericForeignKey
relationship in Django models
Experience Level - Expert
How is Password saved in the database in django framework?
Experience Level - Beginner
How does Django Migrations work?
Experience Level - Beginner/Intermediate
- Answer- Coming Soon
What are mixins? Have you written any custom mixin? Why?
Experience Level - Intermediate/Expert
What is 1:1 , M2M and Foreign key concept in django models?
Experience Level - Beginner
- Answer- Coming Soon
How is the name of the table mapped between the database and the models.py
? How can you update it?
Experience Level - Beginner
- Answer- Coming Soon
What is the difference between prefetch_related
and select_related
? When to use which one?
Experience Level - Intermediate/Expert
select_related
performs SQL join to fetch data from related tables. Majorly used forOneToOneField
orForeignKey
field.prefetch_related
fires 2 queries, first it would fetch the ids from the first table and then it would make another query to fetch the details from other table using the ids extracted in the first query. Majorly used forManyToManyField
or reverseForeignKey
lookups.
Explain Signals in Django.
Experience Level - Intermediate/Expert
- Answer- Coming Soon
What is Request-Response cycle in Django?
Experience Level - Beginner/Intermediate
- Answer- Coming Soon
What is a Middleware and when do you use a middleware?
Experience Level - Intermediate/ Advance
- Answer- Coming Soon
How does ORM work?
Experience Level - Beginner
What is the purpose of wsgi.py
file?
Experience Level - Intermediate
- Answer- Coming Soon
What is Abstract Model Concept?
Experience Level - Beginner/Intermediate
- Answer- Coming Soon
What is Proxy Model?
Experience Level - Intermediate/Expert
- Answer- Coming Soon
What is Multi-table Inheritance?
Experience Level - Intermediate/Expert
- Answer- Coming Soon
What is class Meta
in django models? Where is it used?
Experience Level - Beginner/Intermediate
What is Django admin?
Experience Level - Beginner
What is the use of apps.py
in every Django app?
Experience Level - Intermediate/Expert
Explain how does urls.py
work?
Experience Level - Beginner/Intermediate
What is TEST_RUNNER
in Django?
Experience Level - Expert
What is the difference between STATIC_URL
and MEDIA_URL
?
Experience Level - Beginner/Intermediate
What is the use case of ALLOWED_HOSTS
in settings.py
?
Experience Level - Intermediate/Expert
What is the difference between filter
and get
in Django ORM?
Experience Level - Beginner
Explain Django sessions.
Experience Level - Beginner
If you are looking for python interview questions. Please go through my curated list of python questions