Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Django 9 questions

Django Views & URL Routing

Build routing patterns. Differentiate class-based views (CBVs) from function-based views (FBVs), URL patterns, namespace redirects, and context processing.

More Django
Interview questions 1–9 of 9
1

What is the difference between function-based views (FBVs) and class-based views (CBVs) in Django?

AspectFunction-based viewsClass-based viewsDefinitionA plain Python functionA Python class extending View or a...

Read answer →
2

How does Django's URL routing work with path() and re_path()?

FunctionPattern syntaxUse casepath()Simple converters like <int:pk>Most common URLs - clean, readablere_path()...

Read answer →
3

What are Django's generic class-based views like ListView, DetailView, and CreateView?

Generic CBVs implement common view patterns (listing, detail display, create/update/delete forms) with minimal...

Read answer →
4

What is the difference between render(), redirect(), and HttpResponse in Django views?

Function/classPurposeStatus codeHttpResponse()Raw response with arbitrary content200 by defaultrender()Renders...

Read answer →
5

What are Django mixins and how do you use them with class-based views?

Mixins are reusable classes that add specific behavior to a CBV through multiple inheritance, letting you comp...

Read answer →
6

How do you handle GET and POST request data in Django views?

Data sourceAccess viaTypical useQuery string (?key=value)request.GETSearch, filters, paginationForm-encoded PO...

Read answer →
7

What is Django's CSRF protection and how does it work with views?

Django's CsrfViewMiddleware protects against Cross-Site Request Forgery by requiring a secret token to be pres...

Read answer →
8

How do you use get_object_or_404() and get_list_or_404() in Django views?

These shortcut functions fetch an object or list, automatically raising an Http404 exception (rendering a 404...

Read answer →
9

How do you organize URLs using include() and app namespacing in Django?

include() lets you delegate a URL prefix to another app's urls.py, keeping the project's main URL configuratio...

Read answer →