- Download and install python 3 from https://www.python.org/
- Create a virtual environment (https://peps.python.org/pep-0405/) and activate the same
- Install Django within the virtual environment
- On the command prompt run, 4.1) "django-admin startproject mysite && cd mysite" to create a project 4.2) "python manage.py runserver" to run the django webserver
- On your browser, visit "http://127.0.0.1:8000/" to access the site
- On command prompt run, 6.1) "python manage.py startapp polls" to create the app
- In an editor, open "polls/views.py", add the below snippet and save, from django.http import HttpResponse def index(request): return HttpResponse("Hello, world. You're at the polls index.")
- Create "urls.py" within "polls" app folder in an editor, add the below snippet and save, from django.urls import path from . import views urlpatterns = [path('', views.index, name='index'),]
- In an editor, open "mysite/urls.py", add the below snippet and save, from django.contrib import admin from django.urls import include, path urlpatterns = [ path('polls/', include('polls.urls')), path('admin/', admin.site.urls), ]
- In an editor, open "mysite/settings.py" and add "polls.apps.PollsConfig" to "INSTALLED_APPS"
- On command prompt run, "python manage.py runserver" to run the django webserver
- On your browser, visit "http://127.0.0.1:8000/" to access the site
- If you get an error page, check that you’re going to http://localhost:8000/polls/ and not http://localhost:8000/
HAPPY LEARNING!
Source: https://docs.djangoproject.com/en/4.0/intro/tutorial01/