25
Introduction to Django #2 SPARCS `08 서서서 (pipoket) `09 Summer SPARCS Seminar

Introduction to Django #2

  • Upload
    varen

  • View
    51

  • Download
    1

Embed Size (px)

DESCRIPTION

Introduction to Django #2. `09 Summer SP ARCS Seminar. SPARCS `08 서우석 ( pipoket ). Last Homework. Download the file http://pipoket.kaist.ac.kr/sp_seminar/django_hw1.tar.gz Extract the downloaded file to any path you want (Refer the Python101, Python102 pdf about extraction) - PowerPoint PPT Presentation

Citation preview

Page 1: Introduction to  Django  #2

Introduction to Django #2

SPARCS `08 서우석 (pipoket)

`09 Summer SPARCS Seminar

Page 2: Introduction to  Django  #2

▶ Last Homework

• Download the filehttp://pipoket.kaist.ac.kr/sp_seminar/django_hw1.tar.gz

• Extract the downloaded file to any path you want(Refer the Python101, Python102 pdf about extrac-tion)

• You have to make a simple web application does…– Get the input from the form– Save the input to the file– Show the entry of the file

Page 3: Introduction to  Django  #2

▶ Last Homework• Form and getting input is already implemented

• What you have to do is…– Implement the “TODO” part on

• “input” and “show” functions• They are in “spseminar/studentinfo/views.py”

– Read the comment carefully (hey, it`s in Korean )– Implement the function as you wish

• You should need Dev. Server.USE THE PORT RANGE BETWEEN 20000-

30000If some port is already taken, use the other port

Page 4: Introduction to  Django  #2

▶ Last Time

Simple Concept of HTTP

Why Django is necessary

How to Install Django

Basic Dev. Flow in Django

Page 5: Introduction to  Django  #2

▶ Helloworld – Timestamp ver.

Django+

Python

처리결과 출력 !

Page 6: Introduction to  Django  #2

▶ What we have learned…

Django Framework

Model(DB)

Con-troller(Code)

View(html)

views.py

Page 7: Introduction to  Django  #2

▶ Helloworld – Stylish ver.

CGI???

Page 8: Introduction to  Django  #2

▶ Django is NOT CGI

Django Framework

Model(DB)

Con-troller(Code)

View(html)

HOW?

Page 9: Introduction to  Django  #2

Django

Template

Only HTML

Django does…Data + HTML

views.pyhel-

loworld.html

date

date + html

Page 10: Introduction to  Django  #2

▶ Making TemplateTemplate 를[ 어디 ] 에 저장할건가 ?

mkdir templates

Django 에게…“Template 가[ 어디 ] 에 저장되어있다”

Edit settings.py

Page 11: Introduction to  Django  #2

▶ Making Template – Edit settings.py

$ vim settings.py

이렇게 세팅하고

Page 12: Introduction to  Django  #2

▶ Making Template – Make helloworld.html

html 에서의 변수선언

Page 13: Introduction to  Django  #2

▶ Using Template – Edit helloworld.py

Template Renderer

render_to_string ( Template File, { var_dictionary })

html 변수 사용하기

Page 14: Introduction to  Django  #2

▶ Template Done!

Page 15: Introduction to  Django  #2

▶ More about Templates

for loop

Calling func.

if state-ment

Other if statements

Page 16: Introduction to  Django  #2

▶ More about Templates

Page 17: Introduction to  Django  #2

▶ Getting Input

로그인 게시판 검색 블로깅뉴스 댓글 싸이월드 방명록

사용자의 입력입력 -> 처리 -> 결과

Page 18: Introduction to  Django  #2

▶ Form

Page 19: Introduction to  Django  #2

▶ Form

Template 로 Form 을 !

views.py 에 Form 을 보여주도록 추가 !

그럼 입력값의 처리는 ?

Page 20: Introduction to  Django  #2

▶ Request

무엇에 쓰는 놈인고 ?

Page 21: Introduction to  Django  #2

▶ Request

Form 으로부터의 입력 값 GET, POST

Django 의 Session 값로그인 정보기타 저장해두고 싶은 값

Page 22: Introduction to  Django  #2

▶ Using Request

request.POST.get( Name at form, Default Value )request.GET.get( Name at form, Default Value)Request.GET.get( Name at URL, Default Value)

Page 23: Introduction to  Django  #2

▶ Using Request

Page 24: Introduction to  Django  #2

▶ Conclusion

Templates

Request

Using Request Form

Page 25: Introduction to  Django  #2

▶ Homework