언어/Python
[디장고 웹 프로젝트 환경설정 및 간단한 게시판]
Ch's Lee
2025. 11. 29. 04:53
Django + React 분리형 웹 프로젝트
1. 개발 환경
OS: Windows
IDE: PyCharm Professional (Educational License)
Python: 3.x (가상환경 venv 사용)
Node.js: 최신 LTS 버전
2. 사용 언어 및 프레임워크
Backend
Python 3.x
Django
Django REST Framework (API 서버)
django-cors-headers (CORS 처리)
Frontend
JavaScript (React)
HTML/CSS
Axios (API 통신)
3. 구성
백엔드: Django REST API 서버 (포트 8000)
프론트엔드: React SPA (포트 3000)
통신 방식: RESTful API (JSON)
인증: JWT 또는 Session (추후 결정)
DjangoProject/
├── .venv/ # Python 가상환경
├── backend/ # Django 프로젝트 설정
│ ├── __init__.py
│ ├── settings.py # Django 설정
│ ├── urls.py # 메인 URL 라우팅
│ ├── asgi.py
│ └── wsgi.py
├── api/ # Django REST API 앱
│ ├── migrations/
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── models.py # 데이터 모델
│ ├── serializers.py # DRF Serializer
│ ├── views.py # API 뷰
│ ├── urls.py # API URL
│ └── tests.py
├── frontend/ # React 프로젝트 (추후 생성)
│ ├── public/
│ ├── src/
│ │ ├── components/
│ │ ├── App.js
│ │ └── index.js
│ ├── package.json
│ └── node_modules/
├── manage.py # Django 관리 스크립트
├── requirements.txt # Python 패키지 목록
└── README.md
설치
[라이브러리 설치]
1 - pip install django djangorestframework django-cors-headers
2 - pip install mysqlclient djangorestframework django-cors-headers
만약, 이미 1를 했다면, pip install mysqlclient 만하기
[ 폴더구조를 위한 설정 ]
npx create-react-app frontend
django-admin startproject backend .
python manage.py startapp api
DB 설계 및 테이블
-- 1. 데이터베이스 생성
CREATE DATABASE IF NOT EXISTS boardPan CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- 2. 사용자 생성
CREATE USER IF NOT EXISTS 'boardPan'@'localhost' IDENTIFIED BY 'boardPan2025!';
-- 3. 권한 부여
GRANT ALL PRIVILEGES ON boardPan.* TO 'boardPan'@'localhost';
-- 4. 권한 적용
FLUSH PRIVILEGES;
-- 5. 확인
SHOW DATABASES;
SELECT User, Host FROM mysql.user WHERE User = 'boardPan';