목록분류 전체보기 (462)
hyeonga_code
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bHD45y/btssqAsb7U4/3ev2bkkZVWzsH0mozKysfk/img.jpg)
- 테이블 추가 1. 경로 추가 > 'urls.py' 'urls.py' ===== 1 2 3 4 5 6 7 from django.urls import path from . import views urlpatterns=[ path('index/', views.index, name='index' ), path('create/', views.create, name='create'), ] Colored by Color Scripter cs 2. 버튼 생성 > > 'index.html' 'index' ===== 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Index Main Page Create #_ 추가 {% for i in f %} {{i.id}} : {{i.c_name}} {%..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/Sm4iW/btssquMhL5o/3KXeAOBPyBfs1SMGnuc3pK/img.jpg)
- 테이블 수정 1. 상세페이지에 수정 버튼 생성 > > 'detail.html' 'detail.html' ===== 1 2 3 4 5 6 7 8 9 10 11 12 13 {{f1.c_name}} CODE : {{f1.c_code}} DETAIL {{f1.c_content}} Update #_ 추가 Main cs 2. 수정 페이지 경로 설정 > 'urls.py' 'urls.py' ===== 1 2 3 4 5 6 7 8 9 10 from django.urls import path from . import views urlpatterns=[ path('index/', views.index, name='index' ), path('create/', views.create, name='create'), path..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/wClkB/btssbhhtm7p/DD9ycl0UN7ubg8ZQWITj7k/img.jpg)
- Context - Http에 테이블 정보 전달 - context : Mapping [str,Any] - return render(request, '앱이름/참조파일.html',context) 1. > 'views.py' 'views.py' ===== 1 2 3 4 5 6 7 8 9 10 11 from django.shortcuts import render from .models import 클래스이름 def 실행함수(request): 변수 = 클래스이름.objects.all() context = { '변수세트' : 변수 } return render(request, '앱이름/참조파일.html', context) cs 2. > > '참조파일.html' '참조파일.html' ===== 1 2 3 4 5 6 ..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/lwbTy/btssquZO3Gk/g6tunhCJE4lwd5GBRmCJo0/img.jpg)
- Admin 생성 1. > 'admin.py' 'admin.py' ===== 1 2 3 4 5 6 7 8 9 10 11 from django.contrib import admin from .models import 클래스이름 # Register your models here. admin.site.register(클래스이름) Colored by Color Scripter cs 2. 터미널 @ python manage.py createsuperuser ===== ''' (mysite) C:\Users\hyeon\mysite\06_if,for> python manage.py createsuperuser Username (leave blank to use 'hyeon'): admin Email address:..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ble5UW/btssk0ShohY/pPlPv98opZAO65gfDFmqS1/img.jpg)
- 테이블_페이지 1. 장고 실행 2. 앱 생성 3. > 'urls.py' 'urls.py' ===== 1 2 3 4 5 6 7 from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('함수이름/', include('앱이름.html')) ] Colored by Color Scripter cs 4. > 'views.py' 'views.py' ===== 1 2 3 4 5 6 from django.shortcuts import render # Create your views here. def 함수이름(request): return render(..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/BigCT/btssbljVuE7/GmsakPzHfqBD6A5oWCsuIK/img.jpg)
- 테이블 생성 - 03_앱생성 1. > 'settings.py' 'settings.py' ===== 1 2 3 4 5 6 7 8 9 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', '앱이름.apps.앱이름_첫글자대문자 + Config' ] Colored by Color Scripter cs 2. > 'models.py' 'models.py' ===== 1 2 3 4 5 6 from django.db import models clas..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bHA0uR/btssfEDcj6d/1E7N3goPGnF3H43u28Z130/img.jpg)
- URL_분리 - 시간 단축을 위함 - render 1) 'settings.py' > Template = [ DIR = [BASE_DIR/'templates']] 2) 'urls.py' > from 앱이름 import views > path('함수이름/', views.'참조파일.html') 3) > > '참조파일.html' > 참조파일 내용 입력 1. 폴더에 폴더 생성 2. 폴더에 폴더 생성 - '참조파일.html' 이동 3. > 'settings.py' 'settings.py' ===== 1 2 3 4 5 6 7 8 9 10 11 12 TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ 'BASE..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bEtlJd/btssgLuM5d6/pmo4H5DiqJSGq0kKxTgblk/img.jpg)
- Render 1. '바탕폴더' 생성 2. 장고 실행 3. 가상화 4. '앱이름' 앱 생성 5. > 'views.py' 'views.py' ===== 1 2 3 4 5 6 7 from django.shortcuts import render def 함수이름(request): return render(request, '참조파일.html') cs 6. '참조파일.html' 생성 '참조파일.html' ===== 1 참조파일 내용 작성 cs 7. > 'settings.py' 'settings.py' ===== 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 TEMPLATES = [ { 'BACKEND': 'dj..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bUEDrO/btssql2S8MZ/iEUX9IS2LOyYyI2KFAKZLK/img.jpg)
- URL_글씨 출력 - 모든 장고 요청은 url을 통해 이루어짐 1. > > 'settings.py' ===== ROOT_URLCONF = 'config.urls' 확인만 2. > > 함수 작성 'views.py' ===== 1 2 3 4 5 6 7 8 9 10 11 12 13 from django.shortcuts import render from django.http import HttpResponse _ 페이지에 글씨 출력하고 싶을 경우 def '함수이름'(request): return HttpResponse( '출력하고싶은내용' ) Colored by Color Scripter cs 3. > > 'urlpatterns' - path('실행이름/', admin.site.urls) - 리스트이므로 ..