Session 2 Creating Apps

You might also like

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

Search . . .

Creating Apps
In Django

Session-2
simrantechmentor
Search . . .

Project & App

Project is a collection of files and folders that are required to create the whole
01 functionality of a product.

In Django we can divide our project into multiple Apps.


02

03 Apps help us to manage a project as it provides clean separation between logical


functionalities.

simrantechmentor
Search . . .

Project & App

In Django Project one minimum app is required.


04

Creating a project into multiple apps also allow you to reuse a particular app in another
05
project.

simrantechmentor
Search . . .

Lets Create App


Software Search . . .

01 Visual Studio Code

simrantechmentor
Step 1. Open Visual Studio Click Search . . .

Open Folder

simrantechmentor
Step 2. Select your project Search . . .

simrantechmentor
Step 3. Open Terminal as Search . . .

command prompt
1

simrantechmentor
Step 4. Activate Virtual Search . . .

Environment

01 In terminal window type “workon <virtualenvname>”


For example : workon test

simrantechmentor
Step 5. Create Your app Search . . .

In terminal window type “py manage.py startapp <<appname>”


01
For example : py manage.py startapp demoapp

simrantechmentor
Let’s Explore important App Files Search . . .

simrantechmentor
models.py file Search . . .

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

It is the one of the core concept of Django framework


02

It allows us to completely define the database of web application


03

simrantechmentor
models.py file Search . . .

04 Model is a class that represent tables in our Database

Every class we create in models.py will be inherit from Model class.


05

06 Each attribute of Model class will represent a database field

simrantechmentor
models.py file Search . . .

simrantechmentor
views.py file Search . . .

01 This file contains view functions that takes a web request and returns a web response.

02 In simple language in vies.py file we place our business logic of application

simrantechmentor
views.py file Search . . .

simrantechmentor
apps.py file Search . . .

01 It is the entry point of Python Application

02 This file is used to configure some attributes of the application.

simrantechmentor
Step 6. Create urls.py file in app Search . . .

Create urls.py file in your app.


01

simrantechmentor
Step 7. Update urls.py file in app Search . . .

Update file with following code.


01

simrantechmentor
Step 8. Update urls.py file in project Search . . .

Update file with following code.


01

simrantechmentor
Step 9. Update views.py file in project Search . . .

Update file with following code.


01

simrantechmentor
Step 10. Run server and check output Search . . .

01 py manage.py runserver

02 Open browser : type 127.0.0.1:8000/

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