Menu
CoddyTech

Hello, Django

Part of the Django Basics section of Coddy's Django journey. Lesson 1 of 23.

Corner Café has a new website, and its home page still shows a placeholder.

Your browser asks a server for a page: that is a request. The server sends the page back: the response. Django is a Python framework for writing that server. This function in menu/views.py answers the home page:

from django.http import HttpResponse


def home(request):
    return HttpResponse("Hello from Django!")

A function like this is a view. Django calls it when a request arrives, and the text in the HttpResponse it returns is the page.

Run starts the site beside your code, like python manage.py runserver on a laptop.
challenge icon

Challenge

Easy

Make the home page say Welcome to Corner Café instead of Hello from Django!.

Press Run: the site beside your code shows your words.

Try it yourself

from django.http import HttpResponse


def home(request):
    return HttpResponse("Hello from Django!")

All lessons in Django Basics

Practice on your own: Django playground