Django Views

0 0
Read Time:36 Second

Django Views

Django views are Python functions that takes http requests and returns http response, like HTML documents.

A web page that uses Django is full of views with different tasks and missions.

There is a views.py in your example folder that looks like this:

from django.shortcuts import render

# Create your views here.

Find it and open it, and replace the content with this:

from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
def members(request):
    return HttpResponse("Hello world!")

This is a simple example on how to send a response back to the browser.
But how can we execute the view? Well, we must call the view via a URL.

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Comment