Cheat-sheat project for Django Template system to showcase the configuration and dynamic HTML page rendering. For newcomers, Django is a high-level Python Web framework that encourages rapid development by reusing modules and libraries built by experienced programmers. Django Templates help us to build dynamic pages, reuse components, and code faster web applications.
Django is an opinionated framework that provides a complete set of tools for web development, from URL routing to form handling and user authentication. It promotes best practices in web development through its structure and conventions, encouraging developers to write maintainable and scalable code. Django’s middleware system allows for global processing of requests and responses, enabling the implementation of complex features like session handling and caching with minimal effort.
$ pip install django
A curated list with Django Dashboards actively supported by the App-Generator Platform.
Open-source Django Starter crafted on top of AdminLTE, an open-source Bootstrap
Design. The product is designed to deliver the best possible user experience with highly customizable, feature-rich pages.
- 👉 Django AdminLTE -
Product Page
- 👉 Django AdminLTE -
LIVE Demo
- Simple, Easy-to-Extend Codebase
- AdminLTE Design Integration
- Bootstrap CSS Styling
- Session-based Authentication, Password recovery
- DB Persistence: SQLite (default), can be used with MySql, PgSql
- Apps:
- Django CLI Package
Commit/rollback Git Changes
Backup & restore DB
Interact with Django Core
Manage Environment
Manage Dependencies
- Deployment
- Docker/Docker Compose Scripts
- CI/CD for Render
Open-source Django project crafted on top of Datta Able, an open-source Bootstrap
design released by CodedThemes.
The product is designed to deliver the best possible user experience with highly customizable, feature-rich pages.
- 👉 Django Datta Able -
Product Page
- 👉 Django Datta Able -
LIVE Demo
- Simple, Easy-to-Extend Codebase
- Datta Able Design Integration
- Dynamic Tables - generate data tables without coding
- Dynamic API - expose secure APIs without coding
- CLI for Coding Tasks
Commit/rollback Git Changes
Backup & restore DB
Interact with Django Core
via CLIUpdate Environment variables
Update Dependencies
- Bootstrap 5 Styling
- Session-based Authentication, Password recovery
- DB Persistence: SQLite (default), can be used with MySql, PgSql
- Docker, CI/CD for Render
- Vite for assets management
How to build the project
Step #1 - Clone the sources
$ git clone https://github.com/app-generator/django-templates.git
$ cd django-templates
Step #2 - Create and activate a virtual environment
$ # Virtualenv modules installation (Unix based systems)
$ virtualenv env
$ source env/bin/activate
$
$ # Virtualenv modules installation (Windows based systems)
$ # virtualenv env
$ # .\env\Scripts\activate
Step #3 - Install Django
$ pip install django
The config
directory contains at least two relevant files:
config/settings.py
- global project settingsconfig/urls.py
- project routing rules
Sample_app
directory, created with python manage.py startapp
will serve the html
files from templates
directory. According to the product configuration, HTML pages are located in the templates
directory.
# Contents of config/settings.py
...
TEMPLATES_DIR = os.path.join(BASE_DIR, "templates") # <- Specify where the directory is located
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATES_DIR], # <- Informs Django about it
'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',
],
},
},
]
...
index.html - showcases a simple file
On access the ROOT
of the app or simply index.html
a simple file is served from templates
directory.
variables.html - Display in the HTML page a simple variable sent by the Django backend
{{ variable }}
lists.html - iterate over a simple list with integers
<h4>The List:</h4>
<ul>
{% for i in list %}
<li>{{ i }}</li>
{% endfor %}
</ul>
Footer Component - a common footer is used by all sample pages
{% include "includes/footer.html" %}
Thanks for reading! Feel free to suggest more topics related to Django Templates using the issues tracker
.
- Django Templates - a free chapter from
The Django Book
- Django Templates - a really nice article provided by
GeeksForGeeks
platform
Django Templates - Open-source project provided by App Generator