To create a view, we need an app to be created first. Let's say courses.
After that, inside app(courses) folder, create views.py
To create a sample view: -------------------- apps(courses)\views.py -- from django.http import HttpResponse def index(request): return HttpResponse("Hello World.") apps(courses)\urls.py -- from django.urls import path from .import views urlpatterns = [ path('', views.index, name="index") ] To link apps specific urls.py to main project root urls.py root\urls.py -- from django.urls import include, path urlpatterns=[ path('courses/', include('courses.urls')), ]
No comments:
Post a Comment