Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekaputra07/django-menuz
Drag and Drop Menu manager for Django. Mostly inspired by how menu creation in WordPress.
https://github.com/ekaputra07/django-menuz
Last synced: 5 days ago
JSON representation
Drag and Drop Menu manager for Django. Mostly inspired by how menu creation in WordPress.
- Host: GitHub
- URL: https://github.com/ekaputra07/django-menuz
- Owner: ekaputra07
- License: bsd-3-clause
- Created: 2012-07-24T04:51:12.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-02T02:30:52.000Z (almost 11 years ago)
- Last Synced: 2024-12-16T11:12:07.012Z (22 days ago)
- Language: Python
- Size: 336 KB
- Stars: 8
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
DJANGO MENUZ
============Django Menuz is another menu app for Django.
It mainly inspired by how easy menu creation ini WordPress. Django Menuz provides
template tags to call menu in specified location.With it's drag and drop features, its easy to re-order the menu item position.
INSTALLATION AND USAGE:
-----------------------
Once you install it via setup.py, easy_install or pip.* Add ``menuz`` into your ``INSTALLED_APPS`` Django ``settings.py`` file.
* Please make sure ``django.core.context_processors.request`` available in your ``TEMPLATE_CONTEXT_PROCESSORS``.
* Also add url config below into projects urls configuration.
::
url(r'', include('menuz.urls')),* Register all available menu positions in project ``settings.py`` by adding ``AVAILABLE_MENUS`` parameter. example:
::AVAILABLE_MENUS = (
{
'id': 'top_menu',
'title': _('Top Menu'),
'type': 'UL', #optional, default UL. alternative 'OL'
'class': 'someclass', #optional, output:
- BBBTitle
-
TitleAAA - {{item.title}}
'before_link': 'BBB', #optional, can be text or html tag. output:
'after_link': 'AAA', #optional, can be text or html tag. output:
},
{
'id': 'footer_menu',
'title': _('Footer Menu'),
'type': 'UL',
'class': None,
},
{
'id': 'left_menu',
'title': _('Left Menu'),
'type': 'OL',
'class': None,
},
)
* If you have few fix/static url into your application and want to include so it's will be selectable as a menu items, add ``AVAILABLE_INNERLINKS`` in your project ``settings.py``.
::
AVAILABLE_INNERLINKS = (
('/this_page/', 'This Page'),
('/that_page/', 'That Page'),
('/categories/', 'Categories Page'),
('/collections/', 'Collections Page'),
...
...
etc.
)
* Above links must inbound link, not links to other sites(outbound link).
* For Outbound link menu, use Custom link in menu creation admin page.
MODEL MENU
----------
* To create a menu based on Django model items, simply create ``menu.py`` in application directory, this is in the same level as application urls.py and register our model as following example (file: ``menu.py``).
::
# file: menu.py
from menuz.registry import menuz
from catalog.models import Product
menuz.register(Product)
* Or if you want to do some filtering before registering it into menuz do as follows (file: ``menu.py``).
::
from menuz.registry import menuz
from catalog.models import Product
def active_product():
return Product.objects.filter(active=True)
menuz.register(Product, custom_source=active_product)
We registering extra callback that will be called when menuz will display selectable menu items in admin area,
that way, the menu item selector will not display all available products, but will display active products only.
IMPORTANT:
----------
To make Model menu items links correctly to its url, your model must utilize ``get_absolute_url()`` function. Because this is the only standard way to retrieve object urls, at least for django-menuz.
example:
::
from django.db import models
class Page(models.Model):
title = models.CharField(max_length=50)
slug = models.SlugField()
@models.permalink
def get_absolute_url(self):
return ('some_page', None, {'slug': self.slug})
CALLING MENU ITEMS IN TEMPLATE
------------------------------
**example calling menu items as html list**
::
{% load 'menuz_tags' %}
{% list_menu 'top_menu' %}
**example calling menu items as template context**
This implementation does not support hierarchical menu, please use ``list_menu`` tag if you need that feature.
::
{% load menuz_tags %}
{% get_menu top_menu as tmenu %}
{{tmenu_title}}
{% for item in tmenu %}
{% endfor %}
Please note on the above example, when you assign a menu to a variable named ``somevar``, you can display the menu title by adding ``_title`` suffix after the variable name.
In the case above, the variable name is ``tmenu`` and the title will be available in variable named ``tmenu_title``.
TESTING
-------
In case you want to run a test for this app, you need to install Django-nose first https://pypi.python.org/pypi/django-nose (please refer to Django-nose docs on how to install).
Then run the test by running command below:
::
python manage.py test menuz