django
DESCRIPTION
Django is a high-level Python Web framework that encourages rapid development, pragmatic design and follows DRY principles.TRANSCRIPT
![Page 1: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/1.jpg)
Django is a high-level Python Web framework that encourages rapid development, pragmatic design and follows DRY principles.
By Abhijeet ShekharBlog: http://ashekhar.wordpress.com
![Page 2: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/2.jpg)
Features• Legacy DB• Test Framework• Multi- DB• Geodjango• Aggregation• JSON Serializer• Stable API Promise• Fantastic Docs
• Generic View• Template Inheritance• Template Filters• Humanize• Runs on Jython /Iron
Python• Google App Engine
![Page 3: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/3.jpg)
Architecture
![Page 4: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/4.jpg)
Component Architecture
![Page 5: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/5.jpg)
Django is MTV/MVP framework
-Model (app/models.py-Template ( app/templates/*.html)-View (app/view.py)
![Page 6: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/6.jpg)
Project Structure
-project= the full website app=python library
-Sample--__init__.py--settings.py--urls.py--wsgi.py-app-1--_init_.py--admin.py--models.py
--tests.py--urls.py--view.py-app-2
template/manage.pyenv/readme
![Page 7: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/7.jpg)
Environment setup and installationStandard installation:• Content will be stored in the default location of
pythonVirtual installation:• All dependent library can be installed in the virtual
environment.• one project will be one virtualenv.• Every project with different dependencies in terms
of libraries and version.• Easier to deploy and forget dependency• Virtualenvwrapper is a convenient
![Page 8: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/8.jpg)
Steps to create a project• Create a project• Start an application• Create your database(Mysql, Post gre)• Configure DB settings in settings.py• Define your models• Add external modules• Add your template• Write your view• Create url mappping• Test application• Deploy application (linux apache , mod
python
![Page 9: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/9.jpg)
$ django-admin.py startproject <project_name>$ cd <project_name>$ Python manage.py startapp my$ edit settings.py and set DB info$ python manage.py runserverBrowse http://localhost:8000
Initialize Your Project
![Page 10: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/10.jpg)
Settings:
-multiple setting files:-per environment: dev, testing, staging , Production Per developer (local settings, use the host name )
-all setting file must inherit from , so you can doINSTALLED_APPS +=(‘debug_toolbar’)-version control all the setting !
![Page 11: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/11.jpg)
Fat models, thin viewer…
-multiple setting files:-per environment: dev, testing, staging , productionPer developer (local settings, use the host name )
-all setting file must inherit from , so you can doINSTALLED_APPS +=(‘debug_toolbar’)-version control all the setting !
![Page 12: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/12.jpg)
Debugging
- ipython (./mange.py shell)- Ipdb- Import ipdb- Ipdb.set_trace()- django-debug-toolbar- very powerful- use it to optimze db performance, view by view
![Page 13: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/13.jpg)
Migration
- South/migrate: - Intelligent schema & data migrations for Django- Can do backward migrations
![Page 14: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/14.jpg)
Deployment
Web server- Niginx/Apache- wsgi- mod_python
Static server- Nginx or any CDN
![Page 15: Django](https://reader035.vdocuments.mx/reader035/viewer/2022062704/555da3dbd8b42a45788b5643/html5/thumbnails/15.jpg)
Thanks