mkdir backend
cd backend
python -m venv venv
source venv/Scripts/activate
pip install django
pip install djangorestframework _drf 용도_
django-admin startproject config .
npx create-react-app frontend
cd frontend
yarn start
yarn start 후 성공하면 다음과 같은 화면이 실행됨!
- Ctrl+C 누르면 실행 종료
pip install django-webpack-loader
1) INSTALLED_APPS에 'webpack_loader', 'rest_framework' 추가
2) TEMPLATES에 DIRS 수정
'DIRS': [os.path.join(BASE_DIR,"templates"),],
3) STATICFILES_DIRS 추가
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'assets'),
)
4) WEBPACK_LOADER 추가
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.dev.json'),
'POLL_INTERVAL': 0.1,
'TIMEOUT': None,
'IGNORE': [r'.+\.hot-update.js', r'.+\.map'],
'LOADER_CLASS': 'webpack_loader.loader.WebpackLoader',
}
}
현재 디렉토리 구조 !
{% load render_bundle from webpack_loader %}
<!DOCTYPE html>
<html>
<body>
{% render_bundle 'main' %}
</body>
</html>