Function-based views basics
📖 Scenario: You are building a simple Django web app that shows a welcome message on the homepage.This app uses function-based views to handle web requests.
🎯 Goal: Create a Django function-based view that returns a simple HTTP response with the text "Welcome to my site!" when the homepage is accessed.
📋 What You'll Learn
Create a function-based view named
home_view in views.pyThe view must return an
HttpResponse with the exact text "Welcome to my site!"Add a URL pattern in
urls.py that maps the root URL '' to home_viewUse only function-based views, no class-based views
💡 Why This Matters
🌍 Real World
Function-based views are the simplest way to handle web requests in Django apps, useful for small projects or simple pages.
💼 Career
Understanding function-based views is essential for Django developers to build and maintain web applications.
Progress0 / 4 steps