Django & Bootstrap v5

Django & Bootstrap v5 guide for Trezo.

Overview

Django is a high-level Python web framework known for its speed, security, and scalability. It follows the “batteries-included” philosophy, offering a comprehensive toolkit for building complex applications, with features like ORM, authentication, and templating out-of-the-box. Its clean, modular approach simplifies back-end development, ensuring code maintainability and consistency.

Bootstrap v5, the latest version of the popular front-end framework, brings a sleek and responsive design system that enhances user experience across devices. With a refined grid system, reusable components, utility classes, and no dependency on jQuery, Bootstrap v5 is optimized for modern web applications.

Pairing Django with Bootstrap v5 brings together Django’s robust back-end capabilities and Bootstrap’s visual and responsive front-end design, allowing developers to rapidly build applications that are both functionally complex and aesthetically engaging. Django handles server-side logic and data management, while Bootstrap v5 ensures the front-end is intuitive and adaptable, creating a full-stack solution perfect for scalable, user-centered applications.

What is Django?

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Ridiculously fast.Reassuringly secure.Exceedingly scalable.
Django was designed to help developers take applications from concept to completion as quickly as possible.Django takes security seriously and helps developers avoid many common security mistakes.Some of the busiest sites on the web leverage Django’s ability to quickly and flexibly scale.

Learn more about Django

Installation Guide

Step 1: Install Python 3.x.y

  • Ensure that Python 3.x.y is installed on your system. You can download the latest version from the official Python website. Make sure to check the option to “Add Python to PATH” during installation.

To verify the installation, open your terminal or command prompt and run:

python3 --version

You should see the installed Python version.

Step 2: Install pip (Python Package Manager)

  • pip is a package manager that allows you to install Python packages/modules. For Python versions 3.4 or later, pip comes pre-installed.

To verify if pip is installed, run:

pip3 --version

If it’s not installed, follow the instructions on the official pip installation guide.

Step 3: Install virtualenv

  • virtualenv is used to create isolated Python environments. It’s a good practice to use it for every project to avoid conflicts between dependencies.

To install virtualenv, use the following command:

pip3 install virtualenv

Step 4: Set Up the Virtual Environment

Navigate to the trezo_django project directory using the terminal:

cd path/to/trezo_django

Once inside the project directory, create a virtual environment. You can name it anything you like (e.g., myenv or venv).

To create and activate the virtual environment, use the following commands:

For Linux/macOS:

python3 -m venv myenv      # Create a virtual environment
source myenv/bin/activate   # Activate the virtual environment

For Windows:

python -m venv myenv        # Create a virtual environment
myenv\Scripts\activate       # Activate the virtual environment

You should now see the virtual environment’s name in your terminal prompt.

Step 5: Install Django

With the virtual environment activated, install Django using pip:

pip3 install django

Step 6: Run Migrations

Django uses a database to store data. Before you can run the server, you need to set up the database by applying migrations. Use the following command:

python3 manage.py migrate

This will create the necessary database tables for your Django project.

Step 7: Start the Django Development Server

To start the local development server, run:

python3 manage.py runserver

This will start the server on http://127.0.0.1:8000/. Open this URL in your browser to see the Django application running.

And that’s it! You’ve successfully set up and launched your trezo_django project. Let us know if you run into any issues during the installation process!

In Brief

   Navigate to the trezo_django directory and create a virtual environment:
   - python3 -m venv myenv
   - virtualenv venv
   - source venv/bin/activate
   - pip3 install django
   - python3 manage.py migrate
   - python3 manage.py runserver
   - http://127.0.0.1:8000/