Jango
Jango
FRAMEWORK:
FRAMEworks are softwarese that is developed
and used by developers to build applications
Ex:
Bottle
Django
Giotto
Flask
Webframework:
It is a software framework that is designed to
support the development of we applications
including
Web services
Webresoureces
Web api’s
Django:
django is a free and open source web
application framework written python
#named after famous guitarist dnago Reinhardt
#created in 2003 open sourced in 2005
ADRIAN HOLOVATY AND SIMON WILLISON
DJANGO OPERATIONS:
PYTHON
HTML
CSS
BOOTSTRAP
VERSISONS:
Present version 3.0
Longtime version 2.2
Features of Django:
Stability
Execlelent documentation
Resolves security issues
Highly scalable
Utilizes seo(serch engine operation)
Huge library of packages
USER
VIEW
REQUEST /RESPONSE
DATABA TEMPLATES
MODEL
SE HTML/CSS/FORMS
MYSQL
SUPPORTS:
Object relational mapping
Multilongual support
Web development withlight weight web server
Urls
HTTP
(urls.py)
REQUEST
FORWARD REQUEST TO
APPROPRIATE VIEW
Model
READ/ View HTTP
(model.py)
(views.py)
WRITE (HTML)
Template
(<filename>.html
MODEL:(storage)
Model:model is going to act as the interface of
your data. It is responsible for maintaining data.
it is the logical data structure behind the entire
application and is representd by a
database(generally relational database such as
mysql,postgres)
File:
Model.py
View:
#view act as link between the model data and the
templates.
#it contains python logics which rquired to web
app
#this view also sends responses to the user when
the application is used, to understand briefly, we
can say that this view.py can deal with
HttpResponse
User
url
view
template
vivew
template:
a template consists of static parts of the dfesired
html output as well as some special syntax
describing how dyanamic content will be inserted
contains:
html
css
bootstrap,javascript
userdjgo use-
>urlviewsmodelviwestemplates
you
web browser
templates(html page)
urls
views
model(database)
database(orm)
model
views
templates
borwser
django setup:
How to create a Django project:
Steps:
Django-admin startproject projectname
Establish connection between views and urls
Userdjangourlviewmodeltemplate
Views.py
def home(request):
return HttpResponse("this is firts project")
def demo(request):
return HttpResponse("<h1>this is demo
program<h1>")
urls.py:
from django.contrib import admin
from django.urls import path
from .views import home,demo
urlpatterns = [
path('admin/', admin.site.urls),
path("",home,name="home"),
path("demo/",demo,name="demo"),
]
C:\Users\hp\Desktop\djangoproject\firstproject1
>py manage.py runserver
http://127.0.0.1:8000/
settings.py:
configurations
'DIRS': [os.path.join(BASE_DIR,'templates')],
Static files:
Html pages,css,javascript,bootstrap
C:\Users\hp>cd demo
C:\Users\hp\demo>cd scripts
C:\Users\hp\demo\Scripts>activate
(demo) C:\Users\hp\demo\Scripts>
Settings.py configurations:
Static files:
Html,css,bootstrap
Model.py:
It contains the essential filds and behaviors of the
data you’re storing
generally,each model maps to a single database
table.
Create user:
Python manage.py createsuperuser