우분투에 장고 개발 환경 구축하기
3.1.1. 설치 ¶
# apt-get install postgresql python-psycopg2 pgadmin3
설치가 완료되면 postgres (관리 계정) 비밀번호를 변경한다.
# sudo -u postgres psql postgres
postgres=# \password postgres
3.1.2. 사용자 및 DB 생성 ¶
$ sudo -u postgres createuser -D -A -P myuser
이 새 롤에게 또 다른 롤을 만들 수 있는 권한을 줄까요? (y/n) n
$ sudo -u postgres createdb -O myuser mydb
3.2.2. 사용자 및 DB 생성 ¶
$ mysql -u root -p
> CREATE DATABASE mydb;
> CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'some_passwd';
> GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'localhost' WITH GRANT OPTION;
> QUIT;
4. 이클립스에서 프로젝트 생성 ¶File - New - Project - Pydev Django Project
(과정중 django 설치되어 있음에도 불구하고 'django not found' 메시지 출력시
상단 메뉴에서 Window - Preference - Interpreter - Python 에서 인터프리터 제거 후 다시 추가)
Upload new Attachment "c660ab95c3629a7324e8a433b38d76aa.png" or paste a new png picture
Pydev Django Proejct 선택
Upload new Attachment "8dda77f8d559252b1f9c0bedf753b760.png" or paste a new png picture
프로젝트명 기입 후 Next, Next
Upload new Attachment "6efa15a80dc8eebea3e3db299e4b1b3c.png" or paste a new png picture
앞서 생성한 계정 정보를 기입
(사용하는 DB가 MySQL인 경우 mysql, PostgreSQL의 경우 postgresql_psycopg2 를 선택한다.)
src/myproject/settings.py 파일을 열어
- TIME_ZONE = 'America/Chicago' 을 'Asia/Seoul' 로 수정
- LANGUAGE_CODE = 'en-us' 를 'ko-kr'로 수정
5. 설치 테스트 ¶프로젝트 문맥 메뉴 - Django - Run Django Tests(manage.py test) 실행
문제 없는 것을 확인 후
프로젝트 문맥 메뉴 - Run As - Pydev: Django 실행
브라우저를 띄운 후 http://127.0.0.1:8001 접속
7. Admin 활성화 ¶
from django.contrib import admin
admin.autodiscover()
...
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
|
You will be surprised by a loud noise. |












![[http]](/imgs/http.png)