1 / 12

Settings and VIEWS

2011 Django Seminar #4 KAIST 09 학번 차동훈 ( Snogar ). Settings and VIEWS. 필요한 소프트웨어. Python Django 데이터베이스 웹 서버 (Not Necessary). 프로젝트 시작하기. django-admin.py startproject django_bookmarks __init__.py : 디렉토리를 파이썬 패키지로 manage.py : 프로젝트 관리 스크립트 settings.py : 프로젝트 설정

komala
Download Presentation

Settings and VIEWS

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 #4 KAIST 09학번 차동훈 ( Snogar ) Settings and VIEWS

  2. 필요한 소프트웨어 • Python • Django • 데이터베이스 • 웹 서버 (Not Necessary)

  3. 프로젝트 시작하기 • django-admin.py startprojectdjango_bookmarks • __init__.py : 디렉토리를파이썬 패키지로 • manage.py : 프로젝트 관리 스크립트 • settings.py : 프로젝트 설정 • urls.py : URL – Views 연결

  4. DB 설정하기 • settings.py • DATABASE = { • ‘default’: { • ‘ENGINE’ : ‘sqlite3’ • ‘NAME’ : ‘bookmarksdb’ • 여기서는 sqlite3 을 사용한다

  5. 테이블 생성하기 • 설정이 되었으니 DB에 테이블 생성 • 아직 Model엔 아무것도 없는데? 왜? • Django기본 테이블 • python manage.py syncdb • 관리자 계정 생성 • 장고가 제공하는 관리 페이지 접근용

  6. 실행하기 • python manage.py runserver • python manage.py runserver 8001 • python manage.py runserver 0.0.0.0:8000 • 127.0.0.1:8000 • 127.0.0.1:8001 • 143.248.234.205:8000

  7. It worked!

  8. App • 어플리케이션 • View와 Data Model의 묶음 • 홈페이지를 기능별로 구분하기 위함 • OTL::모의 시간표 • OTL::과목 사전 • python manage.py startapp bookmarks • models.py : 데이터 관리 • views.py : 데이터를 처리하는 로직 관리

  9. 메인 페이지를 만들어 보자

  10. 메인 페이지를 만들어 보자 • Urls.py • 접속했을 때 main_page함수를 호출하고 싶다 • from bookmarks.views import * • urlspatterns = patterns(‘’, • (r’^$’, main_page), • ) • Regular Expression • http://docs.python.org/lib/module-re.html

  11. 실행해 볼까요?

  12. 과제 • Models.py 에 Bookmark 모델을 만들어보세요! • 제목 • 이 Bookmark의 User • 이 Bookmark의 Link • Given: • class Link(models.Model): • url = models.URLField(unique=True) • from django.contrib.auth.modelsimport User • 확인: • python manage.py sql bookmarks

More Related