Unit 4: Forms in Django - Subjective Questions

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

20 questions

1

Define a web form. Explain the purpose and main components of forms in Django.

2

Describe the complete form-processing cycle in a Django application.

3

Explain the GET method and its use in Django forms with a suitable example.

4

Explain the POST method and show how POST data is handled in a Django view.

5

Distinguish between GET and POST methods in the context of Django forms.

6

Explain how HTTP requests and responses are represented and used by Django while processing forms.

7

Construct a Django form class for collecting a user's name, email address, age, and message. Explain the fields used.

8

Describe different methods of rendering a Django form in a template. Why must the HTML <form> element be written explicitly?

9

What are fields and widgets in Django forms? Compare their responsibilities with examples.

10

Differentiate between bound and unbound forms in Django. How are errors and previously entered values preserved?

11

Write and explain a Django view that displays a form, validates POST data, and processes cleaned_data.

12

What is Cross-Site Request Forgery (CSRF)? Explain a typical CSRF attack and its possible consequences.

13

Explain Django's CSRF protection mechanism and demonstrate how CSRF protection is included in a POST form.

14

What happens when Django's CSRF verification fails? Discuss safe practices and the risks of using csrf_exempt.

15

Explain the POST/Redirect/GET pattern. Why is it recommended after successful form submission?

16

Implement the POST/Redirect/GET pattern in Django using a form, view, URL configuration, and template.

17

Describe the data-validation process performed when is_valid() is called on a Django form.

18

Explain three ways to implement custom validation in Django forms: validators, clean_<fieldname>(), and clean().

19

Develop a password confirmation form using cross-field validation. Explain how validation errors should be displayed.

20

Compare Form and ModelForm in Django. Illustrate how a ModelForm can validate and save database data securely.