Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Django #3Introduction to Django #3 SPARCS `08 서우석 (pipoket) `09 Summer SP ARCS Seminar`09 Summer SP ARCS Seminar 2009-07-221SPARCS.

Similar presentations


Presentation on theme: "Introduction to Django #3Introduction to Django #3 SPARCS `08 서우석 (pipoket) `09 Summer SP ARCS Seminar`09 Summer SP ARCS Seminar 2009-07-221SPARCS."— Presentation transcript:

1 Introduction to Django #3Introduction to Django #3 SPARCS `08 서우석 (pipoket) `09 Summer SP ARCS Seminar`09 Summer SP ARCS Seminar 2009-07-221SPARCS

2 ▶ You know DatabaseYou know Database Table Row Record Column Attribute DB (Relational DBMS) DB 2009-07-222SPARCS

3 ▶ Relational DB FormatRelational DB Format Table Column Row 2009-07-223SPARCS

4 ▶ You already have it!You already have it! Your own “Database”! Your own “Format” 2009-07-224SPARCS

5 ▶ What if?What if?data(file)data(file) CollisionCollision 2009-07-225SPARCS

6 ▶ So we use…So we use…models.py 2009-07-226SPARCS

7 ▶ Django = OODBDjango = OODB Student Student.id 2009-07-227SPARCS

8 ▶ What`s the difference?What`s the difference? Originally… SELECT id, name, age FROM student WHERE id=20080003 SELECT id, name, age FROM student WHERE id=20080003 2009-07-228SPARCS

9 ▶ What`s the difference?What`s the difference? In Django… 2009-07-229SPARCS from model import student res = student.get(id=“20080003”) print res.name from model import student res = student.get(id=“20080003”) print res.name

10 ▶Difference! You don`t know SQL You don`t know DBMS Python You only know Python You know python! You know python! OK! 2009-07-2210SPARCS

11 ▶ Creating TableCreating Table models.py Table is also Object! Making Class == Making Table 2009-07-2211SPARCS

12 ▶ Creating Table – Field Types Data TypeField Name integerIntegerField() string (length fixed)CharField(max_length=100) string (long length)TextField() datetimeDateTimeField() booleanBooleanField() 2009-07-2212SPARCS

13 ▶ Notify Django about TableNotify Django about Table 2009-07-22SPARCS13 Add your application with models.py settings.py

14 ▶ Adding DataAdding Data Row is also Object! YOU NEED THIS TO SAVE 2009-07-2214SPARCS

15 ▶ Retrieving dataRetrieving data Getting row object When not found Row == Object !! 2009-07-2215SPARCS

16 ▶ Modifying dataModifying data Get object to modify Modify and Save! 2009-07-2216SPARCS

17 ▶ Deleting dataDeleting data Get object to delete Delete! 2009-07-2217SPARCS

18 ▶Summary Table Define class in models Column Define Fields in class of models Row Create Object with class in models Get Function in class of models Modify Get object, Modify and Save Delete Get object, Call delete function 2009-07-2218SPARCS

19 ▶Practice Change homework of 2 weeks ago. Make it work with database. ….. Okay, Let`s do it together 2009-07-2219SPARCS


Download ppt "Introduction to Django #3Introduction to Django #3 SPARCS `08 서우석 (pipoket) `09 Summer SP ARCS Seminar`09 Summer SP ARCS Seminar 2009-07-221SPARCS."

Similar presentations


Ads by Google