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 details)

Uploaded Source

File details

Details for the file django-simplemenu-simplified-2.0.1.tar.gz.

File metadata

File hashes

Hashes for django-simplemenu-simplified-2.0.1.tar.gz
Algorithm Hash digest
SHA256 a7cf1ab5766cf18b6d171bdde23a3c19c59c1676efc45e33dcab3ee82689eeec
MD5 e5dc0ed49ecb6aee11f33d687dace3a9
BLAKE2b-256 46e40968d3522325bd059caab6c17316e84e07004ff95b1edee2f6df61cc76d9

See more details on using hashes here.

Supported by

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