Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gentle Introduction to Web Development & Django

Gentle Introduction to Web Development & Django

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.

Avatar for Prasanna Venkadesh

Prasanna Venkadesh

June 19, 2013
Tweet

More Decks by Prasanna Venkadesh

Other Decks in Programming

Transcript

  1. I Am Prasanna Venkadesh I Am Prasanna Venkadesh a.k.a Pras

    a.k.a Pras CS Engg. Avid Reader FOSS Activist Citizen of Internet
  2. Where are we today ? Where are we today ?

    1. Past - Web 1.0 2. Present - Web 2.0 3. Future - Web 3.0
  3. How can we build Web pages? How can we build

    Web pages? Simple, all we need to know is HTML + CSS + JS HTML + CSS + JS
  4. HTML - What data should be displayed to user? CSS

    - How it should be displayed? Javascript - Making the page dynamic and interactive.
  5. 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.
  6. How can we build Web How can we build Web

    Applications? Applications? 1. Server - Serve files. 2. Web Framework - handle Web requests 3. Server side scripting - generate contents dynamically
  7. MTV Design MTV Design Model - Data layer Template -

    Presentation layer View - Presentation logic URLs - Acts as a router in Django
  8. $ django-admin.py startproject proj_name This will create a number of

    files & folders in the directory where you are executing this command
  9. Creating an App Creating an App Any number of apps

    can be created inside a project
  10. $ 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.
  11. Sample Code - Model Sample Code - Model # F

    i l e N a m e - m o d e l s . p y f r o m d j a n g o . d b i m p o r t m o d e l s c l a s s U s e r ( m o d e l s . M o d e l ) : n a m e = M o d e l . C h a r F i e l d ( m a x _ l e n g t h = 2 0 ) e m a i l = M o d e l . C h a r F i e l d ( u n i q u e = T r u e )
  12. Sample Code - View Sample Code - View # F

    i l e N a m e - v i e w s . p y f r o m d j a n g o . s h o r t c u t s i m p o r t r e n d e r f r o m d j a n g o . m o d e l s i m p o r t U s e r d e f i n d e x ( r e q u e s t ) : u s e r s = U s e r . o b j e c t s . a l l ( ) c o n t e x t = { ' u s e r s ' : u s e r s } r e t u r n r e n d e r ( r e q u e s t , ' i n d e x . h t m l ' , c o n t e x t )
  13. Sample Code - URLs Sample Code - URLs # F

    i l e N a m e - a p p _ n a m e / u r l s . p y f r o m d j a n g o . c o n f . u r l s i m p o r t p a t t e r n s , i n c l u d e , u r l f r o m p r o j _ n a m e i m p o r t v i e w s u r l p a t t e r n s = p a t t e r n s ( u r l ( r ' i n d e x . h t m l $ ' , v i e w s . i n d e x ) )
  14. $ python manage.py syncdb This command will automatically create tables

    in the database. Schema for the tables are taken from Models.
  15. < Any Questions? > < Any Questions? > Email: [email protected]

    Twitter: @imprashere http://impras.in MTV Image Credit: Thank You Thank You Little Green River blog