Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views1 page

Python Programing-Django Framework-Questions

Uploaded by

VishwaArun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Python Programing-Django Framework-Questions

Uploaded by

VishwaArun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Programing - Django Framework

Exam: Django Framework


Instructions: Answer all questions.

Section A: Short Answer Questions (2 marks each)


1. What is the primary purpose of the 'HttpResponse' object in Django? (2 marks)
2. Explain the role of the 'urls.py' file in a Django project. (2 marks)
3. What is the significance of the 'request.GET' dictionary in Django? Give an example of how it is used. (2
marks)
4. Describe the purpose of the 'include()' function within the 'urlpatterns' list in Django's 'urls.py'. (2 marks)
5. What command is used to start a new app in a Django project? (2 marks)

Section B: Long Answer Questions (16 marks each)


1. a) Explain the steps involved in setting up a basic Django project and running the development server. (8
marks)
b) Describe the purpose of 'manage.py' file. (8 marks)
2. a) Write a Django view function that takes two integer parameters, 'a' and 'b', from the URL's GET request,
calculates their sum, and returns the result as an HTTP response. (8 marks)
b) Create the corresponding 'urls.py' entry to map a URL pattern (e.g., '/sum/') to this view function. (8 marks)
3. a) Explain how Django uses templates to separate presentation from logic. Describe the process of rendering
a template with context data. (8 marks)
b) Create a simple HTML template that displays a variable named "message" passed from a Django view. (8
marks)
4. a) Describe the steps required to create a new Django app and integrate it into an existing Django project.
Include the necessary modifications to 'urls.py' files. (8 marks)
b) Explain the concept of URL namespaces and how they can be used to avoid URL conflicts between different
apps in a Django project. (8 marks)
5. Based on the "personal webpage" example in the chapter context:
a) Explain the structure of the 'myweb/views.py' file and how it dynamically constructs the webpage by com-
bining header, mode-specific content, and footer HTML files. (8 marks)
b) Discuss the advantages and disadvantages of this approach to building dynamic web pages compared to
using Django's template engine. (8 marks)

Keynotes:
* Core Concepts: Django installation and configuration, project and app creation, URL routing, view functions,
HTTP requests and responses, GET parameters, template rendering (basic), file handling within views.
* Key Topics: 'HttpResponse', 'urls.py', 'request.GET', 'include()', 'manage.py', template basics, app integration,
URL namespaces, dynamic webpage construction.

You might also like