Added better custom template
This commit is contained in:
parent
9b082fdc64
commit
27c8c8f10b
6 changed files with 19 additions and 29 deletions
|
@ -1,13 +1,12 @@
|
|||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class CustomHeaderBG():
|
||||
"""Allow custom header background"""
|
||||
|
||||
class Template(TemplateView):
|
||||
header_BG = ""
|
||||
class CustomTemplate(TemplateView):
|
||||
html_title = ""
|
||||
body_class = ""
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['header_BG'] = self.header_BG
|
||||
context['html_title'] = self.html_title
|
||||
context['body_class'] = self.body_class
|
||||
return context
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
from django.views.generic import TemplateView
|
||||
from project.common.views import CustomHeaderBG
|
||||
from project.common.views import CustomTemplate
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
|
||||
|
||||
class IndexView(TemplateView):
|
||||
class IndexView(CustomTemplate):
|
||||
template_name = 'index.html'
|
||||
html_title = "Homepage"
|
||||
body_class = "index"
|
||||
|
||||
|
||||
class NoJavascriptView(TemplateView):
|
||||
class NoJavascriptView(CustomTemplate):
|
||||
template_name = 'core/no-js.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
@ -16,7 +17,7 @@ class NoJavascriptView(TemplateView):
|
|||
return context
|
||||
|
||||
|
||||
class Custom404View(CustomHeaderBG.Template):
|
||||
class Custom404View(CustomTemplate):
|
||||
template_name = 'core/404.html'
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
@ -24,9 +25,9 @@ class Custom404View(CustomHeaderBG.Template):
|
|||
return self.render_to_response(context, status=404)
|
||||
|
||||
|
||||
class AboutWebsiteView(CustomHeaderBG.Template):
|
||||
class AboutWebsiteView(CustomTemplate):
|
||||
template_name = 'about/website.html'
|
||||
|
||||
|
||||
class AboutIndexView(TemplateView):
|
||||
class AboutIndexView(CustomTemplate):
|
||||
template_name = 'about/index.html'
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
{% extends 'content_base.html' %}
|
||||
|
||||
{% block htmlTitle %}About the website{% endblock %}
|
||||
|
||||
{% block bodyClass %}{% endblock %}
|
||||
|
||||
{% block pageTitle %}About my website{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% block baseHtmlTitle %}{% endblock %} | TheOrangeOne</title>
|
||||
<title>{{ html_title }} | TheOrangeOne</title>
|
||||
<meta chatset='utf-8' />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
||||
<script type="text/javascript" src="{% static 'js/jquery.js' %}"></script>
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"/>
|
||||
<link rel="shortcut icon" href=""/>
|
||||
</head>
|
||||
<body class="{% block baseBodyClass%}{% endblock %}">
|
||||
<body class="{{ body_class }}">
|
||||
{% block baseContent%}{% endblock %}
|
||||
<footer>
|
||||
<div class="container">
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block baseHtmlTitle%}
|
||||
{% block htmlTitle %}{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block baseBodyClass %}
|
||||
{% block bodyClass %}{% endblock %}
|
||||
{% endblock%}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block baseHtmlTitle %}Homepage{% endblock %}
|
||||
{% block baseBodyClass %}index{% endblock %}
|
||||
{% block baseContent%}
|
||||
<div class="container-fluid" id="header">
|
||||
<div class="jumbotron container animated zoomInDown">
|
||||
|
|
Reference in a new issue