카테고리 없음

django - 가상환경으로 간단한 웹사이트 만들기

까자미가 카카로트냐 2020. 2. 16. 12:56

1. make a directory

2. python -m venv 만들디렉토리이름

3. PS C:\DEV\aProject\env\Scripts> & .\activate 

    source is a shell command designed for users running on Linux (or any Posix, but whatever, not Windows).

4. 가상환경으로 들어옴

    (languageDict) C:\python_work\venvproject\languageDict\Scripts>  

    (languageDict) C:\python_work\venvproject\languageDict\Scripts>pip install django

5. maria db install 

6. 시작>mariadb>mariadb_client 

show databases;

create database table;

use table;

7.  python 과 mariadb 연결하기 위한 드라이버 설치

   pip install libmysqlclient-dev

   or,    pip install mysqlclient

   or,    설치 실패시에 아래 경로에서 .whl 파일 다운로드 
   https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
 

9. settings.py

DATABASES = {

'default': { #'ENGINE': 'django.db.backends.sqlite3',

              #'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

'ENGINE': 'django.db.backends.mysql',

'NAME': 'db-name', #mysql

'USER': 'db-user-name', #root 'PASSWORD': 'db-password', #1234

'HOST': 'db-adress', #공백으로 냅두면 default localhost 'PORT': 'port-number' #공백으로 냅두면 default 3306 } }

 

9.

    python manage.py makemigrations

    python manage.py migrate