https://github.com/averageencoreenjoer/tree-menu-project
Django application for creating, managing and displaying tree menus with strict requirements for performance and functionality. The solution is ideal for sites with multi-level navigation, complex structural menus and a requirement for minimal database load.
https://github.com/averageencoreenjoer/tree-menu-project
bootstrap5 ci-cd django django-templates django-test-framework docker docker-compose github-actions gunicorn postgresql python3 sqlite whitenoise
Last synced: 2 months ago
JSON representation
Django application for creating, managing and displaying tree menus with strict requirements for performance and functionality. The solution is ideal for sites with multi-level navigation, complex structural menus and a requirement for minimal database load.
- Host: GitHub
- URL: https://github.com/averageencoreenjoer/tree-menu-project
- Owner: averageencoreenjoer
- Created: 2025-08-14T10:25:27.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2025-08-14T12:08:16.000Z (2 months ago)
- Last Synced: 2025-08-14T13:25:50.579Z (2 months ago)
- Topics: bootstrap5, ci-cd, django, django-templates, django-test-framework, docker, docker-compose, github-actions, gunicorn, postgresql, python3, sqlite, whitenoise
- Language: Python
- Homepage:
- Size: 166 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ณ Tree Menu Django Application
[](https://www.djangoproject.com/)
[](https://www.postgresql.org/)
[](https://www.docker.com/)This Django application provides functionality for creating and displaying tree menus with compliance with the following requirements:
- The menu is implemented via template tag
- Automatic expansion of the active menu branch
- Storing the menu structure in the database
- Editing via the standard Django admin panel
- Determining the active item by the URL of the current page
- Support for multiple independent menus on one page
- Minimum number of queries to the database (exactly 1 query per menu)## ๐ Features
- **๐ณ Recursive menu** - automatic construction of a tree structure
- **โก๏ธ Optimized queries** - only 1 SQL query for rendering the menu
- **๐งฉ Simple integration** - adding a menu via template tag
- **๐ Admin panel** - convenient management of the menu structure
- **๐ฑ Adaptive design** - Bootstrap 5 for displaying the menu
- **๐ณ Docker containerization** - quick launch in an isolated environment## ๐ฆ Installation
### With Docker (recommended)
1. Clone the repository:
```bash
git clone https://github.com/yourusername/tree-menu-app.git
cd tree-menu-app
```2. Build and run the containers:
```bash
docker-compose up --build
```3. Apply database migrations:
```bash
docker-compose exec web python manage.py migrate
```4. Create a superuser:
```bash
docker-compose exec web python manage.py createsuperuser
```5. The application will be available at: [http://localhost:8000](http://localhost:8000)
### Without Docker
1. Install dependencies:
```bash
pip install -r requirements.txt
```2. Set up the database in `tree_menu_project/settings.py`
3. Apply migrations:
```bash
python manage.py migrate
```4. Create a superuser:
```bash
python manage.py createsuperuser
```5. Run the development server:
```bash
python manage.py runserver
```## ๐ Usage
1. Go to the admin panel: [http://localhost:8000/admin/](http://localhost:8000/admin/)
2. Create a menu, specifying a unique name
3. Add menu items, setting parents if necessary
4. In the Django template, add:```django
{% load menu_tags %}{# Render the menu by name #}
{% draw_menu 'main_menu' %}
```## ๐งช Testing
To run tests, run:
```bash
docker-compose exec web python manage.py test menu
```Or without Docker:
```bash
python manage.py test menu
```Test coverage:
- Models
- Admin panel
- Template tags
- Menu display logic## ๐ Project structure
```
tree_menu_app/
โโโ docker-compose.yml
โโโ Dockerfile
โโโ manage.py
โโโ requirements.txt
โโโ menu/
โ โโโ admin.py
โ โโโ apps.py
โ โโโ migrations/
โ โโโ models.py
โ โโโ templatetags/
โ โโโ templates/
โ โ โโโ menu/
โ โ โโโ menu_template.html
โ โโโ tests.py
โโโ tree_menu_project/
โโโ settings.py
โโโ urls.py
โโโ wsgi.py
```