0% found this document useful (0 votes)
119 views

Django - Student

A web framework provides common patterns for building reliable, scalable web applications. Django is a popular Python-based web framework that follows the model-view-template pattern. It enables rapid development of secure, maintainable websites. Virtual environments allow Django projects to be executed separately without dependency conflicts. Developers create virtual environments, install Django within them, then generate Django projects containing apps, models, views and other core components.

Uploaded by

Praveen Gupta
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)
119 views

Django - Student

A web framework provides common patterns for building reliable, scalable web applications. Django is a popular Python-based web framework that follows the model-view-template pattern. It enables rapid development of secure, maintainable websites. Virtual environments allow Django projects to be executed separately without dependency conflicts. Developers create virtual environments, install Django within them, then generate Django projects containing apps, models, views and other core components.

Uploaded by

Praveen Gupta
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/ 18

THE WEB FRAMEWORK

www.facebook.com/surender.hacker
What is framework?
 A web framework is a code library that makes web
development faster and easier by providing common
patterns for building reliable, scalable and maintainable
web applications.

www.facebook.com/surender.hacker
What is Django?
 Django is a Python-based free and open-source web
framework that follows the model–views–template
architectural pattern.
 It is maintained by the Django Software Foundation, an
American independent organization.

www.facebook.com/surender.hacker
Why is Django?
 Django is a high-level Python web framework that enables
rapid development of secure and maintainable websites.

 Fast
 Secure
 Scalable

www.facebook.com/surender.hacker
MVT framework

www.facebook.com/surender.hacker
Virtual Environment
 The virtual environment is an environment which is used
by Django to execute a project separately.
 It's recommended to install virtualenvwrapper before
installing Django.
 virtualenvwrapper is a set of extensions to virtualenv tool.
 The extensions include wrappers for creating and deleting
virtual environments and making it easier to work on more
than one project at a time without introducing conflicts in
their dependencies.

www.facebook.com/surender.hacker
Virtual Environments

www.facebook.com/surender.hacker
Install virtualenvwrapper
 pip install virtualenvwrapper-win

www.facebook.com/surender.hacker
pip upgrade if available
 …path\python.exe –m pip install –upgrade

www.facebook.com/surender.hacker
Create Virtual Environment for Django
 mkvirtualenv name

 You will be switched into your environment automatically.


 Or you can activate your virtual environment with the
help of following command:
 workon name

www.facebook.com/surender.hacker
Install Django in Virtual Environment
 pip install django

 Note: install Django when you will be into your virtual


environment

www.facebook.com/surender.hacker
Create & Run Django Project
 Run:
 django-admin startproject projectname
 Switch to directory and run:
 manage.py runserver

www.facebook.com/surender.hacker
Access Django Project in Browser

www.facebook.com/surender.hacker
Our Project Contains
 You will get 1 subfolder with project name and 1
manage.py file initially in main project folder.
 After running the server, you will get a database file also
i.e. db.sqlite3

www.facebook.com/surender.hacker
Our Project Contains
 Inside the subfolder, you will get the 5 more files.

www.facebook.com/surender.hacker
Project Files
 manage.py: A shortcut to use the django-admin command-line utility.
It's used to run management commands related to our project. We will
use it to run the development server, run tests, create migrations and
much more.
 __init__.py: It is an empty file that indicates that this folder is a
Python package.
 asgi.py: Asynchronous Server Gateway Interface is a spiritual
successor to WSGI. It provides standard for asynchronous and
synchronous apps.
 settings.py: It contains all the project's configurations.
 urls.py: With the help of this file we can map the routes and paths in
our project. For example, if you want to show something in the URL
/about/, you have to map it here first.
 wsgi.py: This file is a simple Web Server Gateway Interface used for
deployment.

www.facebook.com/surender.hacker
Create an App in Project
 First of all stop your server then go to root directory where
manage.py is stored, now run following command:
 manage.py startapp name
 App will be created here with some default files.

www.facebook.com/surender.hacker
App Files
 migrations/: This folder stores some files to keep track of the
changes done in models.py file, so to keep the database and
the models.py updated.
 admin.py: It is a configuration file for a built-in Django app
called Django Admin.
 apps.py: It is a configuration file of the current app.
 models.py: This is the file where we define the entities of our
Web Application. The models are translated automatically by
Django into database tables.
 tests.py: Used to write unittests for the app.
 views.py: This is the file where we handle the request/response
for our Web Application.

www.facebook.com/surender.hacker

You might also like