반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- programmers
- leetcode
- 키바나
- 스파크
- elasticsearch
- 알고리즘
- ELK
- 깊이우선탐색
- RecommendationSystem
- Spark
- CentOS
- Medium
- Optimization
- Django
- 엘라스틱서치
- 프로그래머스
- daspecialty
- 리트코드
- 파이썬
- Algorithm
- 해시
- dump
- kibana
- dfs
- solution
- Easy
- AWS
- 장고
- twosum
- python
Archives
- Today
- Total
Archive
[Django] Project Home Page (실습4) 본문
반응형
*실습1/실습2/실습3/ 에 이어지는 내용으로, 클래스 뷰 활용
1. 패이지 설계
루트 페이지 생성
1) UI 설계
2) View Flow 설계
2. URLconf
설계한 View Flow를 참고하여 URLconf를 정의
#Djangoproject/urls.py
from django.contrib import admin
from django.urls import path, include
#import view
from djangoProject import views
urlpatterns = [
path('admin/', admin.site.urls),
#루트 페이지 추가
path('', views.HomeView.as_view(), name='home'),
path('polls/', include('polls.urls')),
path('books/', include('books.urls'))
]
3. View
#DjangoProject/views.py
from django.views.generic.base import TemplateView
class HomeView(TemplateView):
template_name = 'home.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['app_list'] = ['polls','books']
return context
4. Template
{% extends "base.html" %}
{% block content %}
<h2>Django Application</h2>
<ul>
{% for appname in app_list %}
{% with appname|add:":"|add:"index" as urlvar %}
<li><a href="{% url urlvar %}">{{ appname }}</a></li>
{% endwith %}
{% endfor %}
</ul>
{% endblock content %}
5. Run Server
$ python manage.py runserver
반응형
'------ Web ------ > Backend' 카테고리의 다른 글
[Django] Book Application 개발 (실습3) (0) | 2022.07.13 |
---|---|
[Django] Class-based View (0) | 2022.07.04 |
[Django] Form (0) | 2022.07.03 |
[Django] Template System (0) | 2022.06.28 |
[Django] Admin (0) | 2022.06.26 |
Comments