Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Render "Hi" | The First Application
Django: Build Your First Website

bookRender "Hi"

In this chapter, we will be working with two files, urls.py and views.py.

  • In views.py, we will write a function that will display a page in the browser with the message "Hello, world!";

  • In the urls.py file, we will create a URL address for our page.

We have the implemented hi view in views.py file.

from django.http import HttpResponse
from django.shortcuts import render
        
# Create your views here.    
def hi(request):
    return HttpResponse("<h1>Hi</h1>")

Import this view to the urls.py and add path to urlpatterns.

from django.urls import path
from .views import hi
        
urlpatterns = [
    path('', hi)
]

Video Explanation

question mark

In which file do you need to write URLs?

Select the correct answer

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 4

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

Awesome!

Completion rate improved to 4

bookRender "Hi"

Scorri per mostrare il menu

In this chapter, we will be working with two files, urls.py and views.py.

  • In views.py, we will write a function that will display a page in the browser with the message "Hello, world!";

  • In the urls.py file, we will create a URL address for our page.

We have the implemented hi view in views.py file.

from django.http import HttpResponse
from django.shortcuts import render
        
# Create your views here.    
def hi(request):
    return HttpResponse("<h1>Hi</h1>")

Import this view to the urls.py and add path to urlpatterns.

from django.urls import path
from .views import hi
        
urlpatterns = [
    path('', hi)
]

Video Explanation

question mark

In which file do you need to write URLs?

Select the correct answer

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 4
some-alt