v4.4

Django & HTML
Bootstrap 5 responsive admin template

documented by Sean Ngu

Last Updated on: 12/July/2024
By: Sean Ngu

Thank you for purchasing my theme. I'd be glad to help you if you have any questions relating to this theme. No guarantees, but I'll do my best to assist.

Follow the following step to install the django in your localhost
You may refer to their official documentation for how to setup the development environment.
Setup Guide

<!-- run the following command --> 
cd /your-path-url/template_django
python manage.py runserver

<!-- browse the url --> 
http://127.0.0.1:8000/

Make sure python >= 3.10 & node.js has been installed on your localhost / server

File structure overview for Django Version

studio_django_v4.4/
├──template_django_startup/            // Version without demo pages
└──template_django/                    // Version including all demo pages
    ├── db.sqlite3                     // SQLite database file
    ├── manage.py                      // Django management script
    ├── Studio/                        // Django project directory
    │   ├── asgi.py                    // ASGI configuration
    │   ├── settings.py                // Django settings
    │   ├── urls.py                    // URL routing
    │   ├── wsgi.py                    // WSGI configuration
    │   ├── __init__.py                // Package initialization
    │   ├── __pycache__/               // Cached Python files
    │   └── templates/                 // HTML templates
    └── StudioApp/                     // Django app directory
        ├── admin.py                   // Admin configuration
        ├── apps.py                    // App configuration
        ├── models.py                  // Database models
        ├── tests.py                   // Unit tests
        ├── urls.py                    // App-specific URL routing
        ├── views.py                   // View functions
        ├── __init__.py                // Package initialization
        ├── __pycache__/               // Cached Python files
        ├── gulp/                      // Gulp build system
        │   ├── gulpfile.js            // Gulp configuration
        │   ├── package.json           // Node.js package file
        │   └── src/                   // Source files for Gulp tasks
        ├── migrations/                // Database migration files
        ├── static/                    // Static files (CSS, JS, images)
        │   ├── css
        │   ├── data
        │   ├── img
        │   ├── js
        │   ├── plugins
        │   └── webfonts
        ├── utils/                     // Utility functions
        │   ├── __pycache__/           // Cached Python files
        │   └── context_processors.py  // Context processors for sidebar array
        └── templates/                 // App-specific HTML templates
            ├── base.html              // Base template
            ├── pages/                 // Demo pages
            └── partial/               // Reusable partial templates
                ├── footer.html
                ├── header.html
                ├── scroll-top-btn.html
                ├── sidebar.html
                ├── theme-panel.html
                └── top-nav.html

We split the header, sidebar, footer and etc into few other part and include it in the base file. Base file has been located in /template_django/StudioApp/templates/base.html.

<!DOCTYPE html>
<html lang="en" {% block htmlAttr %}{% endblock %}>
<head>
  <meta charset="utf-8">
  <title>Studio Django | {% block title %}{% endblock %}</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
  <meta name="author" content="">
  
  <!-- ================== BEGIN core-css ================== -->
  {% load static %}
  <link href="{% static 'css/vendor.min.css' %}" rel="stylesheet">
  <link href="{% static 'css/app.min.css' %}" rel="stylesheet">
  <!-- ================== END core-css ================== -->
  
  {% block css %}{% endblock %}
</head>
<body class="{{ bodyClass }}{% if appHeaderHide is not None %} pace-top {% endif %}" {{ bodyAttr }}>
  
  <div id="app" class="app 
    {% if appSidebarHide is not None %}app-without-sidebar{% endif %}
    {% if appSidebarMinified %}app-sidebar-minified{% endif %}
    {% if appHeaderHide is not None %}app-without-header{% endif %}
    {% if appTopNav %}app-with-top-nav{% endif %}
    {% if appContentFullHeight is not None %}app-content-full-height{% endif %}
    {% if appFooter %}app-footer-fixed{% endif %}
    {% if appBoxedLayout %}app-boxed-layout{% endif %}
  ">
    {% if appHeaderHide is None %}
      {% include 'partial/header.html' %}
    {% endif %}
    
    {% if appSidebarHide is None %}
      {% include 'partial/sidebar.html' %}
    {% endif %}
    
    {% if appTopNav %}
      {% include 'partial/top-nav.html' %}
    {% endif %}
    
    <div class="app-content {{ appContentClass }}">
      {% block content %}{% endblock %}
    </div>
    
    {% include 'partial/theme-panel.html' %} 
    
    {% if appFooter %}
      {% include 'partial/footer.html' %}
    {% endif %}
  </div>

  {% include 'partial/scroll-top-btn.html' %} 
  
  {% block outter_content %}{% endblock %}

  <!-- ================== BEGIN core-js ================== -->
  <script src="{% static 'js/vendor.min.js' %}"></script>
  <script src="{% static 'js/app.min.js' %}"></script>
  <!-- ================== END core-js ================== -->
  
  {% block js %}{% endblock %}
</body>
</html>

Below is a list of supported settings that can be used as context variables in views.py.

Variable Usage
"bodyClass": "pace-top" Set the css class for <body> tag
"appSidebarHide": 1 Set to exclude the sidebar from the page
"appSidebarMinified": 1 Set to minify the sidebar when page load
"appHeaderHide": 1 Set to exclude the header from the page
"appTopNav": 1 Set to include the top-nav to the page
"appFooter": 1 Set to include the fixed footer to the page
"appBoxedLayout": 1 Set to make the page become boxed layout
"appContentFullHeight": 1 Set to make the page content full height
"appContentClass": "p-0" Set the css class for .app-content

Using blocks to add title / css / js / outter content by page level.

// example for how to add page title
{% block title %}Dashboard{% endblock %}

// example for how to add page level css
{% block css %}
  <link href="{% static 'plugins/photoswipe/dist/photoswipe.css' %}" rel="stylesheet">
  ...
{% endblock %}

// example for how to add page level js
{% block js %}
  <script src="{% static 'plugins/photoswipe/dist/photoswipe-ui-default.min.js' %}"></script>
  ...
{% endblock %}

// example of how to add content to the outer app-content div
{% block outter_content %}
  your content here
  ...
{% endblock %}

The sidebar menu is generated in /utils/context_processors.py and rendered globally through /templates/partial/sidebar.html. Below is an example of the sidebar menu array that can be defined in context_processors.py. The sidebar menu will automatically be set to active based on the URL name specified in urls.py.

  sidebar_menu = [{
    'text': 'Navigation',
    'is_header': 1
  },{
    'url': '/',
    'icon': 'fa fa-laptop',
    'text': 'Dashboard',
    'name': 'index'
  }, {
    'icon': 'fa fa-envelope',
    'text': 'Email',
    'children': [{
      'url': '/email/inbox',
      'action': 'Inbox',
      'text': 'Inbox',
      'name': 'emailInbox'
    }]
  }]

All the css files used in Studio has been compiled into two files app.min.css and vendor.min.css by gulp command. You may change the color scheme from /gulp/src/scss/_variables.scss.

vendor.min.css
  1. FontAwesome
  2. jQuery UI
  3. Animate.css
  4. Pace Loader
  5. Perfect Scrollbar
app.min.css
  1. Bootstrap
  2. Studio Core CSS

This theme compiles 6 javascript library into two files app.min.js and vendor.min.js by gulp command.

vendor.min.js
  1. Pace Loader
  2. jQuery
  3. jQuery UI
  4. Bootstrap
  5. Perfect Scrollbar
  6. JavaScript Cookie
app.min.js
  1. Studio Core Javascript

Sidebar minified:

def index(request):
  context = {
    "appSidebarMinified": 1
  }
  return render(request, "pages/index.html", context)

Full height:

def index(request):
  context = {
    "appContentFullHeight": 1,
    "appContentClass": "p-0"
  }
  return render(request, "pages/index.html", context)

Full width:

def index(request):
  context = {
    "appContentFullWidth": 1,
    "appSidebarHide": 1
  }
  return render(request, "pages/index.html", context)

Fixed footer:

def index(request):
  context = {
    "appFooter": 1
  }
  return render(request, "pages/index.html", context)

Boxed Layout

def index(request):
  context = {
    "appBoxedLayout": 1,
    "bodyClass": "pace-top app-with-bg"
  }
  return render(request, "pages/index.html", context)

Top Nav

def index(request):
  context = {
    "appTopNav": 1,
    "appSidebarHide": 1
  }
  return render(request, "pages/index.html", context)

Without Sidebar

def index(request):
  context = {
    "appSidebarHide": 1
  }
  return render(request, "pages/index.html", context)

Without Header

def index(request):
  context = {
    "appHeaderHide": 1
  }
  return render(request, "pages/index.html", context)

Add the theme class to the <body> tag in order to change the theme color.

Available Theme Options

<body class="theme-red">...</body>
<body class="theme-pink">...</body>
<body class="theme-orange">...</body>
<body class="theme-yellow">...</body>
<body class="theme-lime">...</body>
<body class="theme-green">...</body>
<body class="theme-teal">...</body>
<body class="theme-cyan">...</body>
<body class="theme-blue">...</body>
<body class="theme-purple">...</body>
<body class="theme-indigo">...</body>
<body class="theme-black">...</body>
<body class="theme-gray-100">...</body>
<body class="theme-gray-200">...</body>
<body class="theme-gray-300">...</body>
<body class="theme-gray-400">...</body>
<body class="theme-gray-500">...</body>
<body class="theme-gray-600">...</body>
<body class="theme-gray-700">...</body>
<body class="theme-gray-800">...</body>
<body class="theme-gray-900">...</body>

Add the data-bs-theme="dark" attribute to <html> in template_django/StudioApp/templates/base.html order to enable the dark mode.

If you have pre-select the dark-mode option in theme panel, do not forget to clear the browser cookie or remove the theme panel so that it won't affect the dark-mode class while page load.
<html lang="en" data-bs-theme="dark">

To enable RTL mode, follow these steps:

  1. Navigate to the template_django/StudioApp/gulp/src/scss/_variables.scss file in your code editor.
  2. Find the $enable-rtl variable and change its value to true:
    $enable-rtl: true;
    
    This will enable RTL mode for your application.
  3. Save the changes to the file.
  4. Open your terminal or command prompt and navigate to the root directory of your project.
  5. Run the following command to regenerate the app.min.css file:
    gulp
    
    This will regenerate the app.min.css file with the changes you made to the $enable-rtl variable.

Global Variables

The template_django/StudioApp/gulp/src/scss/_variables.scss file contains the variables that control the styles of your application.

To edit these variables, navigate to the template_django/StudioApp/gulp/src/scss/_variables.scss file in your code editor and modify the values of the variables to suit your needs.

<!-- global variable -->
template_django/StudioApp/gulp/src/scss/_variables.scss

Dark Mode Variables

The template_django/StudioApp/gulp/src/scss/_variables-dark.scss file contains the variables that control the styles for dark mode. These variables are used in conjunction with the variables in the template_django/StudioApp/gulp/src/scss/_variables.scss file to provide different values for light and dark modes.

<!-- dark mode variable -->
template_django/StudioApp/gulp/src/scss/_variables-dark.scss

I've used the following images, icons or other files as listed.

Framework

  1. Django: https://www.djangoproject.com/
  2. Python: https://www.python.org/
  3. NodeJs: https://nodejs.org/en
  4. Npm: https://www.npmjs.com/

jQuery Plugins

  1. animate.css: https://daneden.github.io/animate.css/
  2. ApexCharts: https://apexcharts.com/
  3. jQuery File Upload: https://blueimp.github.io/jQuery-File-Upload/
  4. Bootstrap: http://getbootstrap.com/
  5. Bootstrap Icons: https://icons.getbootstrap.com/
  6. Bootstrap Datepicker: https://uxsolutions.github.io/bootstrap-datepicker/
  7. Bootstrap Daterangepicker: http://www.daterangepicker.com/
  8. Bootstrap Slider: https://www.eyecon.ro/bootstrap-slider/
  9. Bootstrap Timepicker: http://jdewit.github.io/bootstrap-timepicker/
  10. Bootstrap Table: https://bootstrap-table.com/
  11. Chart.js: https://chartjs.org
  12. DataTables: https://datatables.net/
  13. FontAwesome: https://fontawesome.com/
  14. Fullcalendar: https://fullcalendar.io/
  15. Iconify: https://icon-sets.iconify.design/
  16. jQuery: https://jquery.com/
  17. jQuery UI: https://jqueryui.com/
  18. jQuery Typeahead: http://www.runningcoder.org/jquerytypeahead/
  19. jquery.maskedinput: https://github.com/excellalabs/jquery.maskedinput
  20. Javascript Cookie: https://github.com/js-cookie/js-cookie
  21. jszip: https://github.com/Stuk/jszip
  22. jVectormap: http://jvectormap.com/
  23. Lity: https://sorgalla.com/lity/
  24. Tag-It: http://aehlke.github.io/tag-it/
  25. Selectpicker: https://picker.uhlir.dev/
  26. Spectrum: https://seballot.github.io/spectrum/
  27. kbw-countdown: https://github.com/kbwood/countdown
  28. moment: http://momentjs.com/
  29. Pace: https://github.com/HubSpot/pace
  30. pdfmake: https://github.com/bpampuch/pdfmake
  31. Perfect Scrollbar: https://github.com/mdbootstrap/perfect-scrollbar
  32. PhotoSwipe: https://photoswipe.com/
  33. PicMo: https://picmojs.com/
  34. Popper.js: https://popper.js.org/
  35. Summernote: https://github.com/summernote/summernote

Photos

  1. Unsplash: https://unsplash.com/
  2. Freepik: https://www.freepik.com/