1 / 18

Model

2011 Django Seminar #2 KAIST 09 학번 차동훈 ( Snogar ). Model. MVC / MVT 패턴 Review. MVC ? Model ( 데이터 ) View ( 사용자 인터페이스 ) Controller ( 데이터를 처리하는 로직 ) MVT ? Model ( 데이터 ) Views ( 데이터를 처리하는 로직 ) Template ( 사용자 인터페이스 ). MVC / MVT 패턴 Review. Model / View / Controller.

rey
Download Presentation

Model

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2011 Django Seminar #2 KAIST 09학번 차동훈 ( Snogar ) Model

  2. MVC / MVT 패턴 Review • MVC ? • Model ( 데이터 ) • View ( 사용자 인터페이스 ) • Controller ( 데이터를 처리하는 로직) • MVT ? • Model ( 데이터 ) • Views ( 데이터를 처리하는 로직) • Template ( 사용자 인터페이스 )

  3. MVC / MVT 패턴 Review • Model / View / Controller User Request Model Controller View

  4. MVC / MVT 패턴 Review • Model / Views / Template User Request Model Views Template

  5. Review • User가 어떤 주소로 접속한다. • Urls.py 에서 맞는 주소를 찾는다. • 그 주소에 해당하는 Views.py의Method를 호출한다. • Template에서 넘긴 정보와 주소에서 넘긴 정보를 이용하여 처리한다. • 이 과정에서 데이터베이스를 이용하여 처리할 수 있다. • 처리한 것을 이용하여 동적 페이지를 작성해 반환한다.

  6. Model?데이터의 형태를 지정IntegerField, CharField, BooleanFieldURLField, DateField, …

  7. Model? • IntegerField : 정수 • CharField : 문자열 • DateField : 날짜 • BooleanField : True/False • URLField : URL • ForeignKey • ManyToManyField • … 필요한 형태를 찾아서 정의하면 된다!

  8. 이런 DB를 생각해보자 • SPARCS 내 세미나가 있고, 각 세미나에 대해 숙제가 있을 수 있다 • 이를 관리하는 서비스를 만들고 싶다 • DB로 어떻게 저장하면 좋을까? • User • Seminar • Homework

  9. 이런 DB를 생각해보자 • User • ID (Necessary) • Password (Necessary) • Name (Necessary) • Email, Nickname, HompageURL, …

  10. 이런 DB를 생각해보자 • Seminar • Name (Necessary) • Administrator • Attender • Start_date(Necessary) • End_date(Necessary) • Description (Necessary)

  11. 이런 DB를 생각해보자 • Homework • Seminar (Necessary) • HwNumber (Necessary) • DueDate (Necessary)

  12. 이런 DB를 생각해보자 • User • ID : 문자열, 15자 이하, Necessary • Id = models.CharField(max_length=15, null=False) • Password : 문자열, Necessary • Password = models.CharField(null=False) • Name : 문자열, 15자 이하, Necessary • Name = models.CharField(max_length=15, null=False) • Email, Nickname, HompageURL, … • Email = models.CharField() …

  13. 이런 DB를 생각해보자 • Seminar • Name : 문자열, 50자 이하, Necessary • Administrator : User 여럿과 연동 • models.ManyToManyField(User) • Attender • models.ManyToManyField(User) • Start_date, End_date : 날짜, Necessary • models.DateField(null=False) • Description : 문자열, 255자 이하

  14. 이런 DB를 생각해보자 • 다대다 대응! hodduc Django bulgom HTML/CSS snogar UI/UX noname ETC

  15. 이런 DB를 생각해보자 • Homework • Seminar : Seminar 하나와 연동, Necessary • models.ForeignKey(Seminar, null=False) • HwNumber : 정수, Necessary • models.IntegerField(null=False) • DueDate : 날짜, Necessary • models.DateField(null=False)

  16. 이렇게 생성한 DB를 확인해보자 • Django에서 models.py 를 DB를 관리하는 SQL문으로 변환

  17. 다음 세미나엔? • Views.py 작성 • 실제로 Django프로젝트를 같이 시작해볼 것! • 먼저 해보고 싶은 사람은 책을 빌려서 해봐 :D • 좀 더 실습 위주의 세미나

  18. 과제 • SQL문이 이렇게 나올 수 있게 Class를 두 개 만들어봐!어디다 작성하든 상관없어!

More Related