Session 1 Introduction To Django

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

Search . . .

Introduction
to
Django
Session-1
simrantechmentor
Search . . .

Django

It is a free and open-source web framework to create web applications.


01

Framework is a combination of packages and components. It helps you start your


02
project with support, so you do not need to do anything from scratch.

03 MVT Architect

simrantechmentor
Django Setup Search . . .

01 Python

02 pip

03 Virtual environment

04 Django

simrantechmentor
Search . . .

Virtual Environment

Virtual environment help you to resolve dependency issue.


01

02 pip install virtualenvwrapper-win


mkvirtualenv test

simrantechmentor
Search . . .

Commands for Project Creation

Django-admin startproject <projectname>


01

cd <projectname>
02

03 py manage.py runserver

simrantechmentor
Search . . .

Demo Time
Pre-Project Steps
Search . . .

Step 1. Install Python (One Time)

simrantechmentor
Search . . .

Step 2. Open command prompt

simrantechmentor
Step 3. Check pip is installed (One Search . . .

time)

simrantechmentor
Search . . .

Step 4. Install virtual Environment

04 pip install virtualenvwrapper-win

simrantechmentor
Search . . .

Create Project
Steps→ Each Project
Search . . .

Common commands to navigate


in command prompt
To change drive type (drivename:) For example ( d:)
01

02 Change Directory : cd

03 To check directory content : dir

simrantechmentor
Search . . .

Common commands to navigate


in command prompt
04 Go inside folder : cd <foldername> Example cd demo

05 cd.. To change parent directory

06 Cd\ move to root drive

simrantechmentor
Search . . .

Common commands to navigate


in command prompt
07 Mkdir to create a make directory. (mkdir <directoryname>)

08 Rmdir to delete directory . (rmdir <directoryname>)

simrantechmentor
Search . . .

Step 1. Create Path for your Projects.


01 Example Lets create a folder where we store all projects. (Example Lets create a folder
“myprojects” in d: drive.

simrantechmentor
Step 2. Create and activate Environment. Search . . .

mkvirtualenv <envname> (One environment for each project)


01
Example “mkvirtualenv demo”

simrantechmentor
Step 3. Activate Environment. (in case Search . . .

Environment is not active)


workon <environment name > workon demo
01

simrantechmentor
Step 3. Install django. Search . . .

pip install django


01

simrantechmentor
Step 4. Check Django version. Search . . .

Django-admin --version
01

simrantechmentor
Step 5 . Create Project. Search . . .

Django-admin startproject <projectname> (Django-admin startproject firstproject)


01

simrantechmentor
Step 6 . Change Project Folder Search . . .

cd <projectname> cd firstproject
01

simrantechmentor
Step 7. Run Server Search . . .

py manage.py runserver
01

simrantechmentor
Step 8. Test Website Search . . .

Open Browser type : http://127.0.0.1:8000/


01

simrantechmentor
Step 9. Close Webserver Search . . .

Press Ctrl+ Break or Ctrl+C


01

simrantechmentor
Step 10. Deactivate Environment Search . . .

Deactivate <environmentname>
01

simrantechmentor
Let’s Explore Project files Search . . .

simrantechmentor
manage.py file Search . . .

01 manage.py file is automatically created in each Django Project

It is a utility that provide various commands that you must have while working with
02
Django project.

03 In simple language it is a command line utility that lets you work with Django project in
various ways.

simrantechmentor
manage.py file Search . . .

01 manage.py file is automatically created in each Django Project

It is a utility that provide various commands that you must have while working with
02
Django project.

03 In simple language it is a command line utility that lets you work with Django project in
various ways.

simrantechmentor
urls.py file Search . . .

01 A URL is a web address. Every page on internet needs its own URL. With the help of URL
your application know which a user wants to see or do.

02 Django has his own way for URL mapping and it is done by editing urls.py file.

simrantechmentor
urls.py file Search . . .

simrantechmentor
settings.py file Search . . .

01 Settings.py is a core file in Django Projects.

02 It holds all the configuration values that your web application need to work.

03 Example : database settings, logging configuration, static file, API keys

simrantechmentor
setting.py file Search . . .

simrantechmentor
wsgi.py file Search . . .

01 Web Server Gateway Interface.

02 It is a specification that describes how a web server communicates with a web


application.

03 WSGI specifies simple rules that the server and application must conform to.

simrantechmentor
asgi.py file Search . . .

01 Asynchronous Gateway Interface.

02 Support Asynchronous calls.

simrantechmentor
Search . . .

THANK YOU
Kindly perform all in class exercise before coming to lab

END SLIDE

simrantechmentor
Contact No : 9878138788
Email : simran@webipher.com

You might also like