쟝고로 홈페이지를 띄웟다면 부트스트랩으로 디자인 템플릿을 입혀보려고 한다.
사용한 디쟌은 아래와 같다.
https://startbootstrap.com/themes/sb-admin-2/
나는 주식관리 페이지이니 Admin/Dashboard 형식으로,,
참고 : https://idlecomputer.tistory.com/91
참고2 : https://stackoverflow.com/questions/1926049/django-templatedoesnotexist
index.html
<!-- Bootstrap core JavaScript-->
<script src='{% static "mainApp/vendor/jquery/jquery.min.js" %}'></script>
<script src='{% static "mainApp/vendor/bootstrap/js/bootstrap.bundle.min.js" %}'></script>
<!-- Core plugin JavaScript-->
<script src='{% static "mainApp/vendor/jquery-easing/jquery.easing.min.js" %}'></script>
<!-- Custom scripts for all pages-->
<script src='{% static "mainApp/js/sb-admin-2.min.js" %}'></script>
<!-- Page level plugins -->
<script src='{% static "mainApp/vendor/chart.js/Chart.min.js" %}'></script>
<!-- Page level custom scripts -->
<script src='{% static "mainApp/js/demo/chart-area-demo.js" %}'></script>
<script src='{% static "mainApp/js/demo/chart-pie-demo.js" %}'></script>
views.py
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.template import loader
def index(request):
template = loader.get_template('mainApp/index.html')
context = {
'latest_question_list': "test",
}
return HttpResponse(template.render(context, request))
urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$',views.index,name = 'index')
]
urls.py
from django.conf.urls import include,url
from django.contrib import admin
urlpatterns = [
url(r'^mainApp/',include('mainApp.urls')),
url(r'^admin/', admin.site.urls),
]
settings.py
SETTINGS_PATH = os.path.dirname(os.path.dirname(__file__))
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# error
# C:\Users\User\Desktop\Django\test_tmp\mainApp\templates\mainApp\index.html
# C:\Users\User\Desktop\Django\test_tmp\mainApp\template\mainApp
#real
'DIRS': [os.path.join(SETTINGS_PATH, 'mainApp/template')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
apps.py
from django.apps import AppConfig
class MainappConfig(AppConfig):
name = 'mainApp'