Python track

Python interview questions and answers

Panel-ready Python & Django questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.

22 Moderate venv Python

How does venv isolate site-packages?

Short take Full answer on next page

Simple meaning

The venv interpreter's sys.prefix points at the env directory, so imports look in venv/lib/site-packages first.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
24 Moderate pip Python

What does pip install -e . do?

Short take Full answer on next page

Simple meaning

Editable install links the project into site-packages so code changes apply without reinstalling.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
26 Moderate Django MVT Python

Walk through Django's request/response cycle.

Short take Full answer on next page

Simple meaning

The WSGI/ASGI handler loads middleware, resolves the URL, and calls the view.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
28 Moderate Django MVT Python

What is a context processor?

Short take Full answer on next page

Simple meaning

A context processor is a function that receives the request and returns a dict merged into every template context.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
31 Moderate ORM Python

What is the N+1 query problem in Django?

Short take Full answer on next page

Simple meaning

N+1 happens when you fetch a list, then access a related field per row, issuing one query plus N more.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
32 Moderate ORM Python

What are F() expressions used for?

Short take Full answer on next page

Simple meaning

F() references a field value in the database so updates happen in SQL, not in Python.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
33 Moderate ORM Python

What are Q() objects?

Short take Full answer on next page

Simple meaning

Q objects let you build complex WHERE clauses with | (OR), & (AND), and ~ (NOT).

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
34 Moderate ORM Python

How do you add a database index on a Django model?

Short take Full answer on next page

Simple meaning

Set db_index=True on a field, or declare indexes in Meta.indexes / unique_together / UniqueConstraint.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
36 Moderate Middleware Python

In what order does Django apply middleware?

Short take Full answer on next page

Simple meaning

On the way in, Django runs middleware from top to bottom of the MIDDLEWARE list.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
38 Moderate Middleware Python

How do you write custom middleware in current Django?

Short take Full answer on next page

Simple meaning

Define a class that takes get_response in __init__ and in __call__ runs pre-logic, calls get_response(request), then post-logic.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
39 Moderate Middleware Python

Why is SecurityMiddleware usually listed first?

Short take Full answer on next page

Simple meaning

It should see the raw request early to apply SSL redirects and refuse bad hosts before other layers do work.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
Prev Page 2 of 5 Next
Chat with us