Skip to main content

A simple menu for Django

Project description

django-simplemenu-simplified

Cloned from https://github.com/althalus/django-simplemenu but make it more simple

A dead simple menu app for Django with ordering in admin interface and ability to link menu item with model instance, view or URL.

It features user-proof admin interface with links for ordering items and limited list of available pages to link to. You should register your views, QuerySets, model instances or URLs to populate that list.

Installation

  1. Run python setup.py install or just place simplemenu directory into a directory which is on your PYTHONPATH.

  2. Add 'simplemenu' to your INSTALLED_APPS setting.

  3. Run python manage.py syncdb.

  4. Register your pages by adding calls to simplemenu.register.

  5. Add menu to your templates.

Note that this application requires Django 1.1 or newer.

Templates

This app has only one tag:

{% get_simplemenu as [varname] %}

It stores QuerySet of all menu items in a context variable. Example:

{% load simplemenu_tags %}
{% get_simplemenu as menu %}
{% for item in menu %}
    <a href="{{ item.page.url }}">{{ item.name }}</a>
{% endfor %}

Highlight visited menu items

It’s relatively simple to handle menu item that links to current page. First, you need to have URL of the page in your template context. The most common way to do it is to add 'django.core.context_processors.request' to the TEMPLATE_CONTEXT_PROCESSORS setting and to use RequestContext in your views. Then you could write in your template the following:

{% load simplemenu_tags %}
{% get_simplemenu as menu %}
<ul>
{% for item in menu %}
    <li {% ifequal item.page.url request.path %}class="selected"{% endifequal %}>
        <a href="{{ item.page.url }}">{{ item.name }}</a></li>
{% endfor %}
</ul>

History

0.1.0 (2018-11-23)

  • First release on PyPI.

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-simplemenu-simplified-2.0.1.tar.gz (11.3 kB view hashes)

Uploaded Source

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