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
- Go to TestModule folder.
- Open views.py and add a new function
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def home(request):
return HttpResponse("Hello")
- Go to urls.py (root_folder/urls.py).
- Add the following code in urls.py
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