0
0
Djangoframework~15 mins

HttpResponse object in Django - Mini Project: Build & Apply

Choose your learning style9 modes available
Basic Django HttpResponse Object
📖 Scenario: You are building a simple Django web app that shows a welcome message on the homepage.
🎯 Goal: Create a Django view function that returns a plain text HttpResponse with a welcome message.
📋 What You'll Learn
Create a Django view function named home
Return an HttpResponse object from the home function
The response content must be exactly "Welcome to my site!"
Import HttpResponse from django.http
💡 Why This Matters
🌍 Real World
Django views use HttpResponse to send data back to the browser. This is how web pages or API responses are created.
💼 Career
Understanding HttpResponse is essential for backend web development with Django. It is a fundamental skill for building web applications.
Progress0 / 4 steps
1
Import HttpResponse
Write an import statement to import HttpResponse from django.http.
Django
Need a hint?

Use the syntax from django.http import HttpResponse to import the class.

2
Define the home view function
Define a function named home that takes one parameter called request.
Django
Need a hint?

Define a function with def home(request):.

3
Return HttpResponse with welcome message
Inside the home function, return an HttpResponse object with the exact text "Welcome to my site!".
Django
Need a hint?

Use return HttpResponse("Welcome to my site!") inside the function.

4
Complete the Django view
Ensure the full code has the import and the home function returning the HttpResponse with the welcome message.
Django
Need a hint?

Check that the import and function are correctly written and complete.