Full Stack Development-Module 1
Full Stack Development-Module 1
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
Full Stack Development with Django
Full Stack Development with Django
Full Stack Development with Django
Caveats??
Take care of headers and blank lines
Database connection per script
Code reusability in multiple
environments
Redesign output page
Full Stack Development with Django
Django Evolution
1. Write a Web application from scratch.
2. Write another Web application from
scratch.
3. Realize the application from step 1 shares
much in common with the application from
step 2.
4. Refactor the code so that application 1
shares code with application 2.
5. Repeat steps 2–4 several times.
6. Realize you’ve invented a framework
Full Stack Development with Django
Full Stack Development with Django
Django MVT (Model –View-Template)
The MVT is a software design pattern which includes
three important components Model, View and
Template.
• The Model helps to handle database. It is a data
access layer which handles the data.
• The Template is a presentation layer which handles
User Interface part completely.
• The View is used to execute the business logic and
interact with a model to carry data and renders a
template.
Full Stack Development with Django
Django
Sends MODEL
requests
View interacts
Checks availability of with Model &
resource in URL Template. Then
USER renders a
VIEW template
URL If url is
mapped View TEMPLATE
Flow of Control in is called
MODEL-VIEW-TEMPLATE At last Django responds
back to the user and sends
a template as a response.
Full Stack Development with Django
Full Stack Development with Django
Characteristics of Django
• Loosely Coupled − Django helps you to make each
element of its stack independent of the others.
• Less code - Ensures effective development
• Not repeated- Everything should be developed in
precisely one place instead of repeating it again
• Fast development- Django's offers fast and reliable
application development.
• Consistent design - Django maintains a clean design and
makes it easy to follow the best web development
practices.
Full Stack Development with Django
Full Stack Development with Django
A Python Virtual Environment is an isolated
space where you can work on your Python
projects, separately from your system-
installed Python.
You can set up your own libraries and
dependencies without affecting the system
Python.
There are no limits to the number of virtual
environments
It is generally good to have one new virtual
environment for every Python-based project
you work on
Full Stack Development with Django
1. Installation of Python, Django and Visual Studio
code editors can be demonstrated.
Python download and installation Link:
https://www.python.org/downloads/
Django installation:
Open a command prompt and type following
command: pip install django
Full Stack Development with Django
2. Creation of virtual environment, Django project
and App should be demonstrated
Virtual Environment Creation
1. Install the Python extension.- Open VS Code IDE and click
extensions there automatically u will be shown Python
extension (Make sure you are connected to Internet)
2. On your file system, create a project folder
3. In that folder, use the following command (as appropriate
to your computer) to create a virtual environment
named env based on your current interpreter:
# Windows
python -m venv env
Full Stack Development with Django
Full Stack Development with Django
Django project and App creation
Open the project folder in VS Code by running code ., or
by running VS Code and using the File > Open
Folder command.
In VS Code, open the Command Palette
(View > Command Palette or (Ctrl+Shift+P)). Then select
the Python: Select Interpreter command
The command presents a list of available interpreters that
VS Code can locate automatically. From the list, select the
virtual environment in your project folder that starts
with ./env or .\env:
Create a New Terminal : In Menu Terminal -> New
Terminal option
Full Stack Development with Django
Creating project:
Type following command in the terminal
opened:
django-admin startproject first .
Full Stack Development with Django
● manage.py: The Django command-line administrative
utility for the project. You run administrative commands
for the project using python manage.py <command>
[options].
● A subfolder named first, which contains the following
files:
o __init__.py:
o wsgi.py:
o settings.py:
o urls.py:
To verify the Django project, make sure your virtual
environment is activated, then start Django's development
server using the command
python manage.py runserver.
Full Stack Development with Django
In the VS Code Terminal with your virtual environment
activated, run the administrative utility's startapp command
in your project folder (where manage.py resides):
URLs in Django
Static URLs
A static URL is a type of URL that does not
change. In technical terms, we can say that these
URL does not contain URL parameters.
Dynamic URLs
A Dynamic URL is a type of URL that can change.
These type of URLs contains special characters
like ? , = , & , + etc.
Full Stack Development with Django
URL: 127.0.0.1:8000/banana,apples,grapes,orange
Output: banana,apples,grapes,orange