Articles in this series
To install Django package with pip on Windows: Open cmd Inside cmd, we can write:py -m pip install Django You can tell Django is installed and which version by running the following command in cmd:py -m django --version
From the command line, cd into a directory where you’d like to store your code, for example, "Desktop" cd desktop Then run the following command to create a project named "PollProject": django-admin startproject PollProject Change directory to create...
Change directory to: "PollProject" folder, where manage.py exists. cd desktop cd PollProject To create our app, we type this command: py manage.py startapp polls
Open the file polls/views.py For example, we open "Sublime Text" software. From File>New Folder> we select: PollProject floder Then put the following Python code in polls/views.py: from django.http import HttpResponse def index(request): retur...
Open up PollProject/settings.py. By default, the configuration uses SQLite. Inside PollProject/settings.py, set TIME_ZONE to your time zone. For example, in my case, it be: TIME_ZONE = 'Asia/Baghdad' To create the tables in the database we run the f...
In our poll app, we’ll create two models: Question and Choice. Edit the polls/models.py file so it looks like this: from django.db import models class Question(models.Model): question_text = models.CharField(max_length=200) pub_date = model...