A Gentle introduction to Web Development & Django

690 views
527 views

Published on

I recently delivered a talk on the topic Introduction to Web development and Django at 5 Day Industrial training programme on Free Software organized by Free Software Foundation Tamil Nadu. This is the presentation I created and used for the talk, which is created using HTML5 and reveal.js.

Published in: Technology, Design
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
690
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

A Gentle introduction to Web Development & Django

  1. 1. Web Dev &Web Dev & DjangoDjango A gentle Introduction
  2. 2. I Am Prasanna VenkadeshI Am Prasanna Venkadesh a.k.a Prasa.k.a Pras CS Engg. Avid Reader FOSS Activist Citizen of Internet
  3. 3. Where are we today ?Where are we today ? 1. Past - Web 1.0 2. Present - Web 2.0 3. Future - Web 3.0
  4. 4. Web 1.0Web 1.0 Mostly STATIC PagesMostly STATIC Pages
  5. 5. Web 2.0Web 2.0 Dynamic ContentsDynamic Contents
  6. 6. Millions of status posts, News Feed, Notifications, etc.,
  7. 7. Millions of Videos being uploaded and played
  8. 8. Especially this one !Especially this one !
  9. 9. & this one !& this one !
  10. 10. Thousands of Music being uploaded and played
  11. 11. Maps, maps, maps everywhere !
  12. 12. Why Web Apps?Why Web Apps? because... Cross-Platform Accessible from anywhere Universal Language
  13. 13. How can we build Web pages?How can we build Web pages? Simple, all we need to know is HTML + CSS + JSHTML + CSS + JS
  14. 14. HTML - What data should be displayed to user? CSS - How it should be displayed? Javascript - Making the page dynamic and interactive.
  15. 15. Web Pages vs Web AppsWeb Pages vs Web Apps
  16. 16. Web Apps are more than a collection of web pages. They can do the following
  17. 17. Get data from UserGet data from User
  18. 18. Process the DataProcess the Data
  19. 19. Retrieve or Display InfoRetrieve or Display Info
  20. 20. In these process of Input - Processing - Output for an Web Application there are number of Web pages involved and that is why I said Web Apps are more than a collection of Web Pages.Web Apps are more than a collection of Web Pages.
  21. 21. How can we build WebHow can we build Web Applications?Applications? 1. Server - Serve files. 2. Web Framework - handle Web requests 3. Server side scripting - generate contents dynamically
  22. 22. Here comes our Show stopper... The Web Framework for Perfectionists with Deadlines.
  23. 23. Django is a Web-FrameworkDjango is a Web-Framework built upon Python
  24. 24. Web frameworks makes development Organized, Structured & FasterOrganized, Structured & Faster
  25. 25. Organized & StructuredOrganized & Structured
  26. 26. MTV DesignMTV Design Model - Data layer Template - Presentation layer View - Presentation logic URLs - Acts as a router in Django
  27. 27. How MTV works?How MTV works?
  28. 28. Creating aCreating a Project in DjangoProject in Django
  29. 29. $ django-admin.py startproject proj_name This will create a number of files & folders in the directory where you are executing this command
  30. 30. Creating an AppCreating an App Any number of apps can be created inside a project
  31. 31. $ python manage.py startapp app_name This will also create a number of files inside a folder 'app_name'. This command should be executed into the Project directory that we created previously.
  32. 32. Create Model, Views & TemplatesModel, Views & Templates
  33. 33. Sample Code - ModelSample Code - Model # File Name - models.py from django.db import models class User(models.Model): name = Model.CharField(max_length=20) email = Model.CharField(unique=True)
  34. 34. Sample Code - ViewSample Code - View # File Name - views.py from django.shortcuts import render from django.models import User def index(request): users = User.objects.all() context = {'users': users} return render(request,'index.html',context)
  35. 35. Sample Code - TemplateSample Code - Template
  36. 36. Sample Code - URLsSample Code - URLs # FileName - app_name/urls.py from django.conf.urls import patterns, include, url from proj_name import views urlpatterns = patterns( url(r'index.html$', views.index) )
  37. 37. $ python manage.py syncdb This command will automatically create tables in the database. Schema for the tables are taken from Models.
  38. 38. $ python manage.py runserver This will start the inbuilt development server at the default port 8000
  39. 39. OutputOutput Url: http://localhost:8000/index.html
  40. 40. Other FrameworksOther Frameworks FlaskFlask
  41. 41. Pylons PyramidPylons Pyramid
  42. 42. Web2PyWeb2Py
  43. 43. < Any Questions? >< Any Questions? > Email: prasmailme@gmail.com Twitter: @imprashere http://impras.in MTV Image Credit: Thank YouThank You Little Green River blog

×