코딩(개발)/Django(11) 홈페이지 제작 실습 STEP 6 (detail - 함수와 클래스 비교) views 에서 로직 구현 한다. 함수형,클래스형 두가지 모두 사용 가능 하지만, 이번에는 클래스형으로 작업. 1. miiusoft\views.py 클래스형 class svc_detail(DetailView): model = svcItems template_name = 'service/svc_detail.html' --->① ① templates\sevice\svc_detiail.html -->파일이 실제 있는 경로 지정 ※ 제네릭 뷰 사용시 명시적으로 지정해 주지 않아도 템플릿파일명은 모델명소문자_detail.html 형식이름으로 지정한다. templates안에 폴더명과 파일명이 모델명과 동일하다면 안써줘도 연결된다. 함수형 def svc_detail(request,pk): svc_detail = ge.. 2021. 1. 18. 홈페이지 제작 실습 STEP 5 (LIST-함수와 클래스 비교) views 에서 로직 구현 한다. 함수형,클래스형 두가지 모두 사용 가능 하지만, 이번에는 클래스형으로 작업. - miiusoft\views.py 함수형 def svc_list(request): context = { } return render(request, "service/svc_list.html", context=context) 클래스형 class svc_list(ListView): model = svcItems template_name = 'service/svc_list.html' context_object_name = 'svcitems' paginate_by = 2 - miiusoft\urls.py #/ssb/list/ 함수형호출 #path("list/", views.svc_list, name=.. 2021. 1. 18. 홈페이지 제작 실습 STEP 4 (DB) 모델(DB table)정의 1. miiusoft\models.py (기본) from django.db import models #서비스아이템등록 class svcItems(models.Model): item_category = models.CharField(max_length=20 , blank=True , null=True) #카테고리 item_name = models.CharField(max_length=200 , blank=True, null=True) #아이템명 item_image = models.ImageField(blank=True, null=True), item_desc = models.TextField(blank=True, null=True) item_detai_linfo = models... 2021. 1. 16. 홈페이지 제작 실습 STEP 3 (공통layout) 전체 같이 쓰는 베이스 페이지 제작 - miiusoft\templates\layout.html - header.html - sidebar.html - footer.html {% load static %} {% include "header.html" %} {% block content %} {% endblock %} {% include "sidebar.html" %} {% block script %} {% endblock %} * 원하는 레이아웃으로 수정 2. 적용방법 {% extends "layout.html" %} {% block content %} {% load static %} welcome to miiusoft {% endblock %} * template 폴더에 들어있는 다른 앱의 베이스페이지들.. 2021. 1. 16. 이전 1 2 3 다음