tasddc1226 / survey-management

설문지들을 관리할 수 있는 설문지 관리 웹서비스 입니다.
0 stars 0 forks source link
django fbv fullstack mysql

survey-management

프로젝트 구조

.
├── README.md
├── config
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── manage.py
├── my_settings.py
├── requirements.txt
└── survey
    ├── admin.py
    ├── apps.py
    ├── forms.py
    ├── models.py
    ├── templates
    │   ├── _base.html
    │   ├── auth
    │   │   ├── login.html
    │   │   └── signup.html
    │   ├── home.html
    │   └── survey
    │       ├── choices.html
    │       ├── create.html
    │       ├── detail.html
    │       ├── edit.html
    │       ├── list.html
    │       ├── question.html
    │       ├── search.html
    │       ├── start.html
    │       ├── submit.html
    │       └── thanks.html
    ├── tests.py
    ├── urls.py
    └── views
        ├── auth.py
        ├── home.py
        └── survey.py

6 directories, 31 files


프로젝트 목표


프로젝트 사용 기술


요구사항 분석


DB Diagram

Untitled


유저 시나리오


설문 관리자 시나리오


설문 참여자 시나리오


API 명세

Method Description Request URL
GET 모든 설문지 리스트 surveys
GET 특정 설문지 조회 surveys/{survey_pk}
POST 설문지 생성 surveys
POST 설문지 질문 생성 surveys/{survey_pk}/question
DELETE 설문지 질문 삭제 surveys/{survey_pk}/question/{question_pk}/delete
POST 설문지 항목 생성 surveys/{survey_pk}/question/{question_pk}/choice
GET 특정 설문지 시작 surveys/{survey_pk}/start
POST 특정 설문지 응답 제출 surveys/{survey_pk}/sumbit/{sub_pk}
POST 설문지 수정 surveys/{survey_pk}/edit
DELETE 설문지 삭제 surveys/{survey_pk}/delete
GET 설문지 제목 검색 surveys/search/?q={query}
GET 설문지 다운로드 surveys/{survey_pk}/download


Local 환경 테스트(MAC OS 기준)

1. 터미널에에서 프로그램을 내려받을 폴더로 이동 (Documents 디렉터리 예시)

% cd ~/Documents

2. git clone으로 파일을 받고 프로젝트 폴더로 이동

% git clone https://github.com/tasddc1226/open-gallery-2022.git
% cd open-gallery-2022

3. 폴더 트리 확인

% ls

# 예시 화면
README.md        __pycache__      config           manage.py        my_settings.py   requirements.txt survey           venv

4. 파이썬 설치 확인

% python --version

# 예시화면
Python 3.8.10

5. 가상환경 생성

% python -m venv venv

6. 가상환경 진입

% source venv/bin/activate

7. 파이썬 모듈 설치

% pip install --upgrade pip
% pip install -r requirements.txt

8. 환경변수 파일 만들기

프로젝트 폴더에서 파일명 my_settings.py를 만들고 아래의 내용을 붙여넣기
# my_settings.py

DATABASES = {
    'default' : {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'open',
        'USER': 'root',
        'PASSWORD': 'mysecretpassword',
        'HOST': 'localhost',
        'PORT': '3306',
    'OPTIONS': {'charset': 'utf8mb4'}
    }
}

SECRET_KEY = 'thisismysecretkey'
DEBUG = True

9. 로컬 환경에 Mysql 설치

이미 Mysql이 설치되어있다면 이 과정은 넘어가도 된다. 만약 brew가 설치되어 있지 않다면 이곳을 참고
% brew install mysql
% brew services start mysql
루트 비밀번호 세팅 (이곳 비밀번호가 8번 환경변수 파일 만들기의 비밀번호에 들어가야한다.)
% mysqladmin -u root password 'mysecretpassword'
터미널에서 mysql 접속확인
% mysql -u root -p
% mysecretpassword

10. database 생성

mysql에 접속하였다면 터미널 명령창이 아래와 같이 mysql> 로 바뀐다.
mysql> create database open character set utf8mb4 collate utf8mb4_general_ci;

11. Django를 이용한 Mysql DB 테이블 생성

프로젝트 폴더(3번 참고)로 이동하여 아래와 같이 입력
% python manage.py migrate

12. Django 서버 실행

프로젝트 폴더에서 아래의 명령어를 입력
% python manage.py runserver