[go: up one dir, main page]

0% found this document useful (0 votes)
13 views6 pages

2 Django02.Notes

The document outlines the steps to set up a Django development environment on Windows 10 or 11, including installing Python and Django, verifying installations, and creating a test project. It also details how to run a local server and create a superuser for website administration. The setup allows for developing and testing Django applications before deployment.

Uploaded by

r95425153
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

2 Django02.Notes

The document outlines the steps to set up a Django development environment on Windows 10 or 11, including installing Python and Django, verifying installations, and creating a test project. It also details how to run a local server and create a superuser for website administration. The setup allows for developing and testing Django applications before deployment.

Uploaded by

r95425153
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PDP 103 | PDP Session 03 | Django Session 02

Setting up a Django development environment


The development environment is an installation of Django on your local
computer that you can use for developing and testing Django apps prior to
deploying them to a production environment.

The main tools that Django itself provides are a set of Python scripts for creating
and working with Django projects, along with a simple development webserver
that you can use to test local (i.e. on your computer, not on an external web
server) Django web applications on your computer's web browser.

Installing Python on Windows 10 or 11

Windows doesn't include Python by default, but you can easily install it from
https://www.python.org

Download the required installer:

Go to https://www.python.org/downloads/windows

Download the most recent supported version of Python e.g. 3.11 that works
with latest version of Django which is 4.1.2

Install Python by double-clicking on the downloaded file and following the


installation prompts

Be sure to check the box labeled "Add Python to PATH"

Verifying the Python Installation

You can then verify that Python 3 was installed by entering the following text
into the command prompt

py -3 -V

Installing Django on the local machine


PDP 103 | PDP Session 03 | Django Session 02

Issue the following command on the command prompt

pip3 install django

For specific version of Django, you can also specify the version number

pip3 install django~=4.0

Verifying the Django installation on Windows

py -3 -m django --version

Verifying the Django installation on Linux Distributions

python3 -m django --version

Testing your installation

To test whether the Django environment is functional and ready to create


Django projects, we need to perform the following steps

Make some directory on the command prompt in the root directory any drive
and then go inside of it

mkdir django_test

cd django_test

Now let’s try to create a new blank project with given Skelton using
django-admin tool. Assuming the project name as mytestsite, issue the
following command on the command prompt

django-admin startproject mytestsite

It creates a project folder with some sub folders and files for you
PDP 103 | PDP Session 03 | Django Session 02

Go inside the folder using cd mytestsite command

Use dir command to view the files and folders in current directory

Run the server using following command

python manage.py runserver


PDP 103 | PDP Session 03 | Django Session 02

Open the web browser and give the following URL to test your sample website
on local machine

http://127.0.0.1:8000/

It will show the following screen

It means your Django Environment Setup is complete and you can start creating
web applications using Django Framework.

Creating super user or administrator for your website administration

 Every website is managed by super user or administrator


 Issue the following command in your project directory to create the super
user

python manage.py createsuperuser

It will ask you username, email id and password then retype the password.
Password will not be displayed (Don’t worry).
PDP 103 | PDP Session 03 | Django Session 02

Now you can login to admin segment of the website using following user

http://127.0.0.1:8000/admin

Enter the userid and password to enter to admin section


PDP 103 | PDP Session 03 | Django Session 02

It means your server is ready to work. Here we can add more users, create
groups and other advance operations to be discussed in next sessions.

You might also like