To override any application template in django, you can set DIRS settings for the django template loader:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
# ./templates/ subdirectory is located at the same folder as ./manage.py
os.path.join(BASE_DIR, 'templates')
],
...
}
To override a part of template, you can create a template with the same name in your templates/ folder, extend it from the corresponding Viewflow template and specify block content to be redefined.
For example, your file $BASE_DIR/templates/viewflow/base.html could looks like
{% extends 'viewflow/base.html' %}
{% load i18n static %}
{% block title %}{{ site.title|default:"Corp. Ink."{% endblock %}
Base site template with all css/js in header included and empty body. Provides current {{ site }} and {{ app }} viewset variables for body of inherited templates.
Redefine to get custom site favicon on the users browser
{% block favicon %}
<link rel="icon" href="{% static 'viewflow/favicon.png' %}" type="image/png" />
{% endblock %}
Website header title
{% block title %}{{ site.title|default:"The Corp. Inc." }}{% endblock %}
Block to add additional css theme stylesheet.
{% block theme %}
<style type="text/css">
:root {
--mdc-theme-primary: #d32f2f;
--mdc-theme-secondary: #01579b;
--mdc-theme--on-primary: #f0f0f0;
}
</style>
{% endblock %}
By default this block contains only –mdc-theme-primary and –mdc-theme-secondary filled with {{ site.primary_color }}, {{ site.secondary_color }} values.
You can find more about theme options at https://material.io/develop/web/components/theme/
Block to include additional site-global styles
{% block css %}
{{ block.super }}
<link href="https://cdn.jsdelivr.net/npm/perfect-scrollbar/css/perfect-scrollbar.css"
rel="stylesheet'>
{% endblock %}
Block to include additional site-global javascript
{% block js %}
{{ block.super }}
<script src="https://cdn.jsdelivr.net/npm/perfect-scrollbar/dist/perfect-scrollbar.common.min.js"></script>
{% endblock %}
Block to include additional css/js on the specific page. The good practice is to override the block on on a specific page template, and leave it empty in the base.html
{% block extrahead %}
<link href="{% static 'css/page-components.min.css' %}" rel="stylesheet">
<script src="{% static 'js/page-components.min.js' %}"></script>
{% endblock %}
Page body content, use this block if you directly extends ‘base.html’
{% block body %}
<aside class="mdc-drawer">
Drawer content
</aside>
<div class="mdc-drawer-app-content">
Lorem ipsum...
</div>
{% endblock %}
Base template for application specific pages. override it to change global drawer appearance: things like user name and avatar. Use as base template for application-wide page template.
{% extends 'viewflow/base_page.html' %}
TODO: Sample...
Place for additional content on the top bar
{% block page-toolbar-extra %}
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end">
<a class="mdc-icon-button material-icons mdc-top-app-bar__action-item"
href="{% url settings %}"
aria-label="Settings">settings</a>
</section>
{% endblock %}
Main page content. To mach visual style of existing pages, whap it “mdc-layout-grid vf-page__grid” classes
{% block content %}
<div class="mdc-layout-grid vf-page__grid">
<div class="mdc-layout-grid__inner vf-page__grid-inner">
<div class="mdc-layout-grid__cell mdc-layout-grid__cell--span-10-desktop">
<div class="mdc-card vf-card">
<div class="mdc-card__primary-action">
<h2 class="mdc-typography mdc-typography--headline6">Sample</h2>
</div>
<div class="mdc-typography mdc-typography--body2">
Lorem ipsum...
</div>
</div>
</div>
</div>
</div>
{% endblock %}
Base template for authentication and error reporting pages
Big icon on the right side of the page.
{% block lockscreen-content-icon %}
<i class="material-icons">lock</i>
{% endblock %}
To use viewflow components and styles outside of viewflow/base.html template, just include corresponding template inside your template <head>
{% include 'viewflow/includes/viewflow_css.html' %}
{% include 'viewflow/includes/viewflow_js.html' %}