Backend/Django

Django 장고 프레임워크 설치 및 기본 세팅

쏠솔랄라 2023. 7. 7. 16:51

 

 

Django : 웹을 만들어 가면서 할 수 있는 프로그램

 

https://www.djangoproject.com/

 

Django

The web framework for perfectionists with deadlines.

www.djangoproject.com

 

 

 

 

Django 페이지로 이동

 

 

 

 

최신 버전은 4.2.3인데 버전 호환성을 고려해 4.1.10버전으로 세팅

 

 


 

 

cmd로 Django 설치 및 기본 세팅

 

 

 

 

Django설치를 위해 cmd > 관리자 권한으로 실행

 

 

 

 

작업할 워크스페이스로 이동

: 하지 않아도 되지만 혹시 모를 상황 때문에 세팅

 

드라이브 이동 후 폴더 위치를 복사한 후 주소 입력

cd 폴더경로

ex. cd C:\Users\Administrator\////////////////////\Django\WorkSpace

 

 

 

 

pip install django==4.1.10

버전 선택하지 않을 경우 최신버전으로 다운로드됨

 

 

Successfully installed 메세지가 뜨면 설치 완료

 

 


 

 

VS Code 세팅

 

 

django 프로젝트 생성

 

 

Terminal에 프로젝트 생성 코드 입력

django-admin startproject Hello

 

 

{
    // IntelliSense를 사용하여 가능한 특성에 대해 알아보세요.
    // 기존 특성에 대한 설명을 보려면 가리킵니다.
    // 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요.
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        },
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "enter-your-module-name-here",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/manage.py",
            "console": "integratedTerminal",
            "args": [
                "runserver",
                "--noreload",
                "--nothreading"
            ],
            "django": true
        },
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "app.py"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "jinja": true
        },
        {
            "name": "Python: Current File (External Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        }
    ]
}

 

 

json 파일 생성 ; 코드 동일하게 입력

 

 

 

 

프로젝트 실행

python 프로젝트명 runserver

python ./Hello/manage.py runserver

 

 

 

 

프로젝트 연결 확인

 

 

추가적인 세팅

 

 

vs code 내 확장팩 설치

 

 

html css suport

 

html의 일부 실행