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

How to use get_or_create in Django?
The TLDR answerThis is one of those two query one command ORM method. It would make a query tothe database with the given where clause query and if not found then it willcreate a new entry in the table using the default values. It returns a tuple which has the object and a boolean field saying w…

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 with accounts 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

What is the difference between blank and null in Django?
null=True would tell the underlying database that this field is allowed to save null. blank=True is applicable in the Django forms layer, i.e. any user is allowed to keep empty this field in Django form or Admin page. blank value is stored in the database.

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 of send(send, **kwargs)
Signals | Django documentation | Django

Explain Django ContentType framework.

Experience Level - Expert

The contenttypes framework | Django documentation | Django

Explain GenericForeignKey relationship in Django models

Experience Level - Expert

The contenttypes framework | Django documentation | Django

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

Class-based views mixins | Django documentation | Django

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 for OneToOneField or ForeignKey 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 for ManyToManyField or reverse ForeignKey lookups.
Select Related Vs Prefetch Related In Django
selected_related and prefetch_related are ways to optimize database queryingpatterns when accessing related items. Both works on the same principle ofprefetching data from the database, however, they take different approaches todo so. We will be using a decorator to print all the stats for the q…

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

Python top interview questions 2021
After working with python for so many years in the industry, I have curated alist of python interview questions for both freshers who are starting theircareer and also for experienced developers who are applying for senior position.I have tried to mark all my questions with relevant experience le…