- 프로젝트이름/urls.py -> 앱이름/urls.py -> 앱이름/views.py -> 앱이름/models.py -> templates/앱이름/HTML파일이름.html
- admin.py : 관리자 사이트
- form.py : 입력 폼 사이트
- 개발 순서 : models.py -> views.py, urls.py, templates
-
startproject
- python -m pip install django~=3.2
- django-admin startproject DDaiso .
- python manage.py runserver
- Enable Django Support
- git 설정
-
startapp product
- python manage.py startapp prouct
- 'product', in INSTALLED_APPS in settings.py
-
product/
-
models
- Product (class)
- name
- price
- python manage.py makemigrations product
- models -> DB를 만들기 위한 py 만들기
- python manage.py migrate product
- DB를 만들기 위한 -> DB 테이블 만들기
- __str__()
- 클래스를 보기 쉽게 하는 함수
- Product (class)
-
admin
- Product
- python manage.py createsuperuser
-
R: Product List
- views
- ProductListView
- urls
- product : list
- templates/product
- product_list.html
- views
-
R: Product Detail
- views
- ProductDetailView
- urls
- product : detail
- templates/product
- product_detail.html
- product_list.html
<a href="{% url 'product:detail' pk=product.id %}">{{ product.name }}</a>
- views
-
C: Aadd Product
- views
- ProductCreateView
- urls
- product : add
- templates
- product_creat.html
- product_list.html
<a href="{% url 'product:add' %}">Add Product</a>
- views
-
U: ProductUpdateView
- views
- ProductUpdateView
- urls
- product:edit
- templates/product
- product_update.html
- product_list.html
- models
- get_absolute_url(): 수정했을 때 성공하면, model의 detail로 가는 함수
- views
-
D: ProductDeleteView
- views
- ProductDeleteView
- urls
- product:remove
- templates
- product_confirm_delete.html
- product_list.html
- models
- views
-
👽🐔😳 기능 완성~!
!!!!~!
-
-
DDaiso/urls
- / -> home(ProductListView)
-
feature/cloudtype
- Local Terminal
- pip freeze > requirements.txt
- Source
- ALLOWED_HOSTS = ['*'] in settings.py
- Sever Terminal
- python manage.py makemigrations
- python manage.py migrate
- Local Terminal
-
feature/boostrap
- extends 'base.html'; block title content
- add DIRS in TEMPLATES in setting.py
- static/css/bootstrap.min.css, static/js/bootstrap.min.js
- add STATIC_ROOT, STATICFILES_DIRS in setting.py
- add Bootstrap class in .html
- pagination
- extends 'base.html'; block title content
-
feature/FBV
- FBV list_product
- product/views
- product/urls
- DDaiso/urls
- FBV detail_product
- product/views
- product/urls
- product/templates/product/product_list.html, product_detail.html
- FBV create_product
- product/forms
- product/views
- product/urls
- product/templates/product/product_list.html
- FBV update_product
- product/forms
- prodduct/views
- product/urls
- product/templates/product/product_list.html, product_detail.html
- FBV delete_product
- product/views
- product/urls
- product/templates/product/product_list.html
- FBV list_product
-
feature/upload_image
-
settings
- MEIDA_ROOT, MEDIA_URL in setting.py
- ulrs
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
- python -m pip install pillow in Teriminal (이미치 처리하는 이미지)
-
models ImageFeild(upload to=)
- product/models
- python manage.py makemigrations product
- python manage.py migrate product
-
admin
-
R: Product List
- product/templates/product/product_list
- templates/base.html
- static/css/style.css
-
R: Product Detail
- product/templates/product/product_detail
- static/css/style.css
-
C: Add Product
- product/forms
- product/views
- product/template/product/product_create
-
U: Edit Product
- product/forms
- product/views
- product/templates/product/product_udpate
-
D: Remove Product
- product/templates/product/product_confirm_delete
-