Skip to main content

Django Theme Material Kit

Open-source Theme for Django styled with Material Kit BS5 Design (free version)

Modern Theme for Django that covers authentication pages (registration included) crafted on top of Material Kit, an open-source Bootstrap 5 design from Creative-Tim.


Links & Resources

  • Django Material Kit - Product that uses the library
    • Features: Fully-configured, CI/CD via Render
  • UI Kit: Material Kit BS5 by Creative-Tim
  • Sections Covered:
    • All pages managed by Django.contrib.AUTH
    • Registration page
    • Misc pages: colors, icons, typography, blank-page

Material Kit - Starter generated by AppSeed.


How to use it​

Install the package via PIP

$ pip install django-theme-material-kit
// OR
$ pip install git+https://github.com/app-generator/django-theme-material-kit.git

Add theme_material_kit application to the INSTALLED_APPS setting of your Django project settings.py:

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",

'theme_material_kit', # <-- NEW
]

Add LOGIN_REDIRECT_URL and EMAIL_BACKEND of your Django project settings.py file:

    LOGIN_REDIRECT_URL = '/'
# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

Add theme_material_kit urls in your Django Project urls.py file.

from django.urls import path, include       # <-- UPD with 'include' directive

urlpatterns = [
...
path('', include('theme_material_kit.urls')), # <-- NEW
]

Collect static if you are in production environment:

$ python manage.py collectstatic

Start the app

$ # Set up the database
$ python manage.py makemigrations
$ python manage.py migrate
$
$ # Create the superuser
$ python manage.py createsuperuser
$
$ # Start the application (development mode)
$ python manage.py runserver # default port 8000

Access the admin section in the browser: http://127.0.0.1:8000/


How to Customize​

When a template file is loaded, Django scans all template directories starting from the ones defined by the user, and returns the first match or an error in case the template is not found. The theme used to style this starter provides the following files:

# This exists in ENV: LIB/theme_material_kit
< UI_LIBRARY_ROOT >
|
|-- templates/ # Root Templates Folder
| |
| |-- accounts/
| | |-- sign-in.html # Sign IN Page
| | |-- sign-up.html # Sign UP Page
| |
| |-- includes/
| | |-- footer.html # Footer component
| | |-- navigation.html # Navigation Bar
| | |-- scripts.html # Scripts Component
| |
| |-- layouts/
| | |-- base.html # Masterpage
| |
| |-- pages/
| |-- index.html # Dashboard Page
| |-- author.html # Profile Page
| |-- *.html # All other pages
|
|-- ************************************************************************

When the project requires customization, we need to copy the original file that needs an update (from the virtual environment) and place it in the template folder using the same path.

For instance, if we want to customize the index.html these are the steps:

  • Step 1: create the templates DIRECTORY inside your app
  • Step 2: configure the project to use this new template directory
    • Edit settings.py TEMPLATES section
  • Step 3: copy the footer.html from the original location (inside your ENV) and save it to the YOUR_APP/templates DIR
    • Source PATH: <YOUR_ENV>/LIB/theme_material_kit/pages/index.html
    • Destination PATH: YOUR_APP/templates/pages/index.html
  • Edit the footer (Destination PATH)

At this point, the default version of the index.html shipped in the library is ignored by Django.

In a similar way, all other files and components can be customized easily.


✅ Resources​