Unit 2: Views and URLs - Subjective Questions

INT253 — Web Development In Python Using Django • Practice Questions with Detailed Answers

20 questions

1

Define a view in Django. Explain its role in processing a web request.

2

Describe the steps required to create a Django view and map it to a URL.

3

Explain how view logic is implemented in a Django function-based view.

4

What is an HttpRequest object in Django? Describe its commonly used attributes.

5

Distinguish between HTTP GET and POST requests in the context of Django views.

6

Explain how Django creates an HTTP response using HttpResponse. Give suitable examples.

7

Compare HttpResponse and the render() shortcut in Django.

8

Explain the structure and purpose of a Django URL configuration.

9

What is the purpose of include() in Django URL mapping? Explain with an example.

10

Describe how dynamic URL parameters are captured and passed to Django views.

11

Explain the built-in path converters available in Django URL patterns.

12

Differentiate between URL path parameters and query-string parameters in Django.

13

Explain named URL patterns and URL reversing in Django. Why should hard-coded URLs be avoided?

14

What is re_path() in Django? Explain how regular expressions can be used in URL patterns.

15

Construct and explain a regular-expression URL pattern that accepts a four-digit year and a two-digit month.

16

Explain the URL resolution process followed by Django when a client requests a page.

17

Describe how a Django view can process both GET and POST requests for a form.

18

Explain how 404 Not Found errors can be handled in Django views.

19

Discuss custom error handlers for HTTP 400, 403, 404, and 500 errors in Django.

20

Explain best practices for creating views, designing URLs, and handling errors in a Django application.