- startproject helloidol
- python -m pip install django~=4.2
- django-admin startproject helloidol .
- [python manage.py migrate]
- python manage.py runserver
- startapp playground
- Terminal
- python manage.py startapp playground
- helloidol/settings.py
- 'playground', in INSTALLED_APPS
- Terminal
- playground/
- 정보 전달: urls -> views -> (models -> )templates
- 코드 작성: (models -> )views -> templates -> urls
- views
- say_hello()
- say_hello_html()
- say_bye_html()
- -> templates에 context 전달
- urls
- playground/hello/ -> say_hello()
- playground/hello_html/ -> say_hello_html()
- templates/playground/
- hello.html
- bye.html
- helloidol/
- urls, playground/urls
- playground/ -> hello/ -> say_hello()
- playground/ -> hello_html/ -> say_hello_html()
- playground/ -> bye_html/ -> say_bye_html()
- urls, playground/urls
- startapp 타이거즈
- Terminal
- python manage.py startapp 타이거즈
- helloidol/settings.py
- '타이거즈', in INSTALLED_APPS
- Terminal
- 타이거즈/
- views
show_도영()show_의리()- -> templates에 context 전달
- 정보를 하나로 묶고, 거기에서 꺼내오자
- show_멤버()
- image link -> image file(static)
- show_멤버리스트()
- templates/타이거즈/
도영.html- title : 타이거즈 - 도영
- h1 : 타이거즈
- h2 : 도영
- img : 도영 프로필 사진
- border-radius : 50%;
의리.html- 맴버.html
- group_name, name, img_src
{% load static %} <img src="{% static img_src %}">
-
{% extends 'base.html' %} {% block title %}{% endblock %} {% block content %}{% endblock %}
- 멤버리스트.html
- {% url '앱이름:path이름' %}
- {% url '앱이름:path이름' 변수=값 %}
-
{% extends 'base.html' %} {% block title %}{% endblock %} {% block content %}{% endblock %}
- urls
타이거즈/ -> 도영 / -> show_도영()타이거즈/ -> 의리 / -> show_의리()- 타이거즈/ -> <멤버>/ -> show_멤버(멤버)
- 타이거즈/ -> 멤버리스트/ -> show_멤버리스트()
- static/타이거즈/images/
- 도영.jpg, 영철.jpg, 의리.jpeg
- views
- templates/
- base.html
{% block title %}{% endblock %} {% block css %}{% endblock %} {% block content %}{% endblock %}
- helloidol/
- in TEMPLATES in settings.py
- 'DIRS': [BASE_DIR / 'templates'],
- in TEMPLATES in settings.py