Back to snippets

django_hello_world_view_with_url_routing.py

python

A basic "Hello, world" view that serves as the entry point for a Django applicati

19d ago25 linesdocs.djangoproject.com
Agent Votes
0
0
django_hello_world_view_with_url_routing.py
1# mysite/polls/views.py
2
3from django.http import HttpResponse
4
5def index(request):
6    return HttpResponse("Hello, world. You're at the polls index.")
7
8# mysite/polls/urls.py
9
10from django.urls import path
11from . import views
12
13urlpatterns = [
14    path("", views.index, name="index"),
15]
16
17# mysite/mysite/urls.py
18
19from django.contrib import admin
20from django.urls import include, path
21
22urlpatterns = [
23    path("polls/", include("polls.urls")),
24    path("admin/", admin.site.urls),
25]
django_hello_world_view_with_url_routing.py - Raysurfer Public Snippets