Skip to main content

DJANGO OUTBOX MENU

Project description

DJANGO OUTBOX MENU

Menu is almost use in every web project.

With this library you can create menu for backend and frontend project without headache. All you need to do is:

In your django Environment

Install package to your environment

> pip install django-outbox-menu

Add to INSTALLED_APPS

INSTALLED_APPS = [        
    'django.contrib.sites', 
    'menu',
]

Add SITE_ID in user settings.py

SITE_ID = 1

Install requirements

Activate your environment using
> mkvirtualenv env_menu
> pip install -r requirements.txt

Migrate to create table to your database

> python manage.py migrate

[OPTIONAL] Import default data to table

> python manage.py loaddata fixtures/menu.json

In your django Templates

Load menu tags

> {% load menu_tags %}

Generate menu

> {% menu_create FRONTEND 0 as my_menu %}     
syntax :
    > menu_create <menu_kind> <menu_group> as var_name
    > menu_kind  : FRONTEND or BACKEND
    > menu_group : 
        0 : None (use only for FRONTEND)
        1 : Owner
        2 : Manager
        3 : Operator
        4 : Cashier
        etc ... (Update in admin page section [Menu Groups])

> {% for n in my_menu %}
    n have all menu fields such as :
    n.id
    n.parent_id
    n.name
    n.link
    n.icon
    n.is_external
    n.level
    n.haveChild
    n.haveChildEndTag
    You can use it inside for loop

> example in you templates
    <ul class="main-menu">
        {% menu_create FRONTEND 0 as my_menu %}                    
        {% for n in my_menu %}

            {% if forloop.first %}                      
                <li class="main-menu-active">
            {% else %}
                <li>
            {% endif %}

            {% if n.haveChild %}
                <a href="#"> {{n.name}}
                    {% if n.parent_id %}
                        <i class="zmdi zmdi-chevron-right text-to-right"></i>
                    {% endif %}
                </a>
                <ul class="sub-menu">                            
            {% else %}                                
                <a class="clear-content-right" href="#"> {{n.name}} </a>                            
            {% endif %}
                                                            
            
            {% for i in n.haveChildEndTag %}
                <!-- Count = {{forloop.counter}} -->
                {% if forloop.last %}
                    {% if n.parent_id %}
                        </li></ul>
                        {% if not n.haveChild %}                                                
                            </li> <!-- li -->                            
                        {% endif %}  
                    {% else %}
                        </li> <!-- Root -->
                    {% endif %}

                {% else %}
                    </li></ul>
                {% endif %}       

            {% endfor %}                            
                                        
        {% endfor %}                                        
    </ul> 

Run project

> python manage.py runserver
on you browser :
127.0.0.1:8000
127.0.0.1:8000/menu
127.0.0.1:8000/admin

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-outbox-menu-1.0.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

django_outbox_menu-1.0.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file django-outbox-menu-1.0.0.tar.gz.

File metadata

  • Download URL: django-outbox-menu-1.0.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for django-outbox-menu-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b054656e38b7541d6f8a1d420e034c9fb13a67636575d9e5c4a2d5504b2a350c
MD5 ecedac5928d85feac50126f11834f85c
BLAKE2b-256 d948c3b69ddac0c7f3bd58cb4ce08f9207dcd88568f8670d351eb929ddcc6b88

See more details on using hashes here.

Provenance

File details

Details for the file django_outbox_menu-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_outbox_menu-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd4cd1437000c581bab4f7c0ed172967d8c485036ffb6debc3fe46420db3d5f6
MD5 82f5c6ab7d12a5e351779a8fa811edeb
BLAKE2b-256 61b8434e98c366f0ac5a42b226b7801973660bb12613bfc5464f97532e659785

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page