Articles → DJANGO → Create our first function-based view in django

Create our first function-based view in django






What is function-based view?





Create your first function-based view








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

# Create your views here.
def home(request):
  return HttpResponse("Hello")






from django.contrib import admin
from django.urls import path
from TestModule.views import home

urlpatterns = [
  path('admin/', admin.site.urls),
  path('', home),
]



Output




<python_path>\python manage.py runserver 8080





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, June 09, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250