bluzir / django_tree_menu_example

Django tree menu example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

django_tree_menu

Django Support

Features

  • Compatible with Django 1.10 and Django >=2.0
  • Any number of nesting levels
  • Easy to add to template
  • Bootstrap 4 example with 3-level menu
  • Doesn't use third-party libraries

Usage

  1. Migrations at first

python manage.py makemigrations menu

python manage.py migrate

  1. Create Menu in admin

Menu admin screenshot

  1. Create child Menu Items for this Menu in admin

Menu items admin screenschot

  1. Optionally add subitems to this Menu Item. In this case menu field must be blank

Menu subitem admin screenshot

  1. In begining of your template add {% load draw_menu %}.

  2. Add this where your Menu should be in template {% draw_menu 'main' %} Where main is your Menu slug.

Examples

  1. Create Menu with slug main and some Menu Items for it
  2. Go to /templates/home.html
  3. Delete comments at lines 5 and 8
  4. python manage.py runserver and go to 127.0.0.1:8000

About

Django tree menu example


Languages

Language:Python 71.9%Language:HTML 21.3%Language:CSS 6.8%