.. _built_in_components: ###################################### Using Built-In Bootstrap 5 Components ###################################### .. index:: single: Built-In Components single: Bootstrap 5 Components Here's a step-by-step tutorial to get you started with ``djangocms-frontend``, a versatile plugin bundle for django CMS that provides a suite of frontend components compatible with various CSS frameworks, including Bootstrap 5. For this tutorial we will be using the built-in Boostrap 5 components that come with ``djangocms-frontend``. Installation ============ To install ``djangocms-frontend``, follow these steps: 1. **Install the package using pip:** .. code-block:: bash pip install djangocms-frontend Alternatively, you can add ``djangocms-frontend`` to your ``requirements.txt`` file and install it via: .. code-block:: bash pip install -r requirements.txt 2. **Install optional dependencies (if needed):** Depending on your project's requirements, you may need additional dependencies: - For icon support with djangocms-icon and not the build-in icon plugin: .. code-block:: bash pip install djangocms-frontend[djangocms-icon] - To include the Ace code editor in static files (if, e.g., your project does not have access to the internet where django CMS loads static ace from a CDN): .. code-block:: bash pip install djangocms-frontend[static-ace] - To install multiple optional dependencies at once: .. code-block:: bash pip install djangocms-frontend[static-ace,djangocms-icon] Configuration ============= 1. **Add Installed Apps** Open your Django project's ``settings.py`` and add the following applications to ``INSTALLED_APPS`` - you only need (and should) add the components you want content editors to use: .. code-block:: python INSTALLED_APPS = [ # Optional dependencies 'djangocms_icon', 'easy_thumbnails', 'djangocms_link', # Required if djangocms_frontend.contrib.link is used # Main frontend components 'djangocms_frontend', 'djangocms_frontend.contrib.accordion', 'djangocms_frontend.contrib.alert', 'djangocms_frontend.contrib.badge', 'djangocms_frontend.contrib.card', 'djangocms_frontend.contrib.carousel', 'djangocms_frontend.contrib.collapse', 'djangocms_frontend.contrib.component', 'djangocms_frontend.contrib.content', 'djangocms_frontend.contrib.grid', 'djangocms_frontend.contrib.icon', 'djangocms_frontend.contrib.image', 'djangocms_frontend.contrib.jumbotron', 'djangocms_frontend.contrib.link', 'djangocms_frontend.contrib.listgroup', 'djangocms_frontend.contrib.media', 'djangocms_frontend.contrib.tabs', 'djangocms_frontend.contrib.utilities', ] 2. **Apply Migrations** Run the following command to create the necessary database tables: .. code-block:: bash python manage.py migrate Adding Styles and JavaScript ============================ ``djangocms-frontend`` does not automatically include CSS or JavaScript files. You need to manually add them to your templates. .. index:: single: base.html 1. **Using Bootstrap 5 templates (recommended to get started quickly)** The package is designed to work with Bootstrap 5 by default. If you want to use Bootstrap 5, extend the default template like this: .. code-block:: django {% extends "bootstrap5/base.html" %} {% block brand %}My Site{% endblock %} This will load Bootstrap 5 CSS and JS from a CDN. .. note:: We recommend developing your own ``base.html`` for your projects. The example templates load CSS and JS files from a CDN. Good reasons to do so are * ``djangocms-frontend`` does not contain CSS or JS files from Bootstrap or any other framework for that matter. The example templates load CSS and JS from a CDN. * It is considered safer to host CSS and JS files yourself. Otherwise you do not have control over the CSS and/or JS that is delivered. * It is a common practice to customize at least the CSS part, e.g. with brand colors. * You might have a totally different build process for your styling assets, especially if you use other frameworks, such as Tailwind CSS. 2. **Custom Templates** If you prefer to manage assets locally, download Bootstrap 5, customize as needed, and include it in your template: .. code-block:: html
Customizing Templates ===================== ``djangocms-frontend``'s built-in templates allow for extensive customization through Django template blocks. Some key blocks you can override: The example template is customisable by a set of template blocks: ``{% block title %}`` Renders the page title. Defaults to ``{% page_attribute "page_title" %}`` ``{% block content %}`` Here goes the main content of the page. The default setup is a ``