본문 바로가기

반응형

전체 글

(202)
Django sqlite3 기초 https://docs.djangoproject.com/en/4.0/intro/tutorial02/ 이미지 썸네일 삭제 Writing your first Django app, part 2 | Django documentation | Django Writing your first Django app, part 2 ¶ This tutorial begins where Tutorial 1 left off. We’ll set up the database, create your first model, and get a quick introduction to Django’s automatically-generated admin site. Where to get help: If you’re having trouble ..
Django에서 Static File 읽어오기 1. Settings.py에 아래 설정을 추가한다. STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join('static'), ) 2. Static 파일을 읽어들이기 위해 html 상단에 아래 코드를 넣는다. {% load static %} 흰 배경흰 배경회색 가로줄 배경회색 가로줄 배경어두운 배경어두운 배경 삭제삭제 3. 사용되는 template html에서 사용하고자 하는 static file은 아래와 같이 지정한다. {% static '' %} 예시
Shell을 이용하여 가상환경 바로 들어가기 가상 환경을 매번 디렉토리 위치 바꿔가며 실행하지 않는 방법 1. 기본 project 폴더에 goenv.sh을 하나 만든다. #! /bin/bash source "/env/bin/activate" 2. 파일이 생성 된 이후에는 아래 명령어만 입력하면 바로 가상 환경에 진입한다. source goenv.sh 3. 서버 구동도 shell로 만들어서 하자. #! /bin/bash python manage.py runserver
Django Template을 이용한 html 호출 1. django.template의 loader를 이용하는 방법 from django.http import HttpResponse from django.template import loader def index(request): template = loader.get_template('HelloWorld/index.html') context = {} return HttpResponse(template.render(context, request)) 2. shortcuts의 render를 이용하는 방법 from django.http import HttpResponse from django.shortcuts import render def index(request): return render(request, ..
Django Project Setup https://docs.djangoproject.com/en/4.0/intro/tutorial02/ 이미지 썸네일 삭제 Writing your first Django app, part 2 | Django documentation | Django Writing your first Django app, part 2 ¶ This tutorial begins where Tutorial 1 left off. We’ll set up the database, create your first model, and get a quick introduction to Django’s automatically-generated admin site. Where to get help: If you’re having trouble ..
Django App 만들기 Project를 만든 후에는 Project 내에서 동작하게 될 기능들을 만들어야하는데 이러한 기능들의 단위를 app이라고 할 수 있다. Project는 app이 모여서 하나의 특정한 website가 된다. app은 project 내의 어느 곳이든 생성 가능하다. Helloworld를 화면에 보여주는 app을 작성해 보자. 1. app 생성 python manage.py startapp HelloWorld $ ls HelloWorld SunnyBlog db.sqlite3 manage.py - HelloWorld App에 자동 생성 된 파일들 SunnyBlog/HelloWorld$ ls __init__.py admin.py apps.py migrations models.py tests.py views.py ..
Django 프로젝트 만들기 및 서버 기동 1. Django 프로젝트 만들기 https://docs.djangoproject.com/en/4.0/intro/tutorial01/ Writing your first Django app, part 1 | Django documentation | Django Writing your first Django app, part 1 ¶ Let’s learn by example. Throughout this tutorial, we’ll walk you through the creation of a basic poll application. It’ll consist of two parts: A public site that lets people view polls and vote in them. An admin s..
Django, 가상환경 설치 1. Django 설치 https://docs.djangoproject.com/en/4.0/intro/install/ Quick install guide | Django documentation | Django Quick install guide ¶ Before you can use Django, you’ll need to get it installed. We have a complete installation guide that covers all the possibilities; this guide will guide you to a minimal installation that’ll work while you walk through the introduction. Install Python ¶ Be..

반응형