Language/Django
-
Django에서 index.html 연결하기Language/Django 2021. 6. 13. 20:56
template 및 index.html 생성 helloworld 앱 안에 template 디렉토리를 하나 생성해주고 그 안에 helloworld 디렉토리를 하나 만들어 준 뒤 그 helloworld 디렉토리 안에 index.html을 만든다 즉, helloworld/template/helloworld/index.html 순서 그 후 html 내용을 작성한다 html 연결을 위한 urls.py, views.py testproject/urls.py와 helloworld/views.py를 다음과 같이 수정해준다 # views.py from django.shortcuts import render # Create your views here. def index(request): return render(reque..
-
Django 앱 생성 및 연결 + HelloWorld! 출력하기Language/Django 2021. 6. 13. 20:55
프로젝트 생성 웹서버 구축 사용한 프로젝트 생성과 같다 'testproject'의 'helloworld' 앱을 예시로 설명할 예정이다 django-admin startproject testproject 앱 생성 manage.py 파일이 있는 프로젝트 폴더 내에 helloworld 앱 폴더를 생성한다. django-admin startproject testproject 프로젝트와 앱 연결 현재 프로젝트와 앱이 따로 존재하는 상태이기 때문에 이를 연결시켜준다 testproject/setting.py를 수정해준다 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contri..
-
Django 설치 및 웹서버 구축Language/Django 2021. 6. 13. 20:53
Django 설치 Ubuntu를 이용하여 터미널에 장고를 설치한다 pip install django 설치과 완료되면 'django' 폴더를 만들고 폴더로 이동한다 mkdir django cd django 프로젝트 생성 django-admin의 startproject 옵션을 사용하여 프로젝트를 생성한다 django-admin startproject 프로젝트이름 개발 서버 구축 python3 manage.py runserver 위 명령어 입력 시 http://127.0.0.1:8000 서버가 생성된다.