Skip to main content

A minimalist Django menu app.

Project description

django-alacarte is a minimalist menu app for Django.

Installation

$ pip install django-alacarte

Usage

Add “alacarte” to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...,
    'alacarte',
)

In your root urls.py add the following code:

# ...

import alacarte
alacarte.autodiscover()

# Your url patterns

Alacarte uses that to automatically discover and load menu.py files inside each one of your INSTALLED_APPS.

Create a file called menu.py inside the app of your choice and register its corresponding menus:

import alacarte


class BankTransactionsMenu(alacarte.Menu):
    label = 'Transactions'
    url_name = 'bank_transactions'


class BankBalanceMenu(alacarte.Menu):
    label = 'Balance'
    url_name = 'bank_balance'


class BankPremiumMenu(alacarte.Menu):
    label = 'Premium Offers'
    url_name = 'bank_premium_offers'

    def shown(self)
        user = self.context['user']
        return user.is_premium()


class BankMenu(alacarte.Menu):
    group = 'main'
    label = 'Bank'
    submenus = (
        BankTransactionsMenu,
        BankBalanceMenu,
        BankPremiumMenu,
    )

    def shown(self):
        user = self.context['user']
        return user.is_authenticated()


alacarte.register(BankMenu)

Then in your template:

{# ... #}
    {# ... #}
    {% alacarte "main" %}
    {# ... #}
{# ... #}

django-alacarte is not related to https://pypi.python.org/pypi/alacarte

Project details


Download files

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

Files for django-alacarte, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size django-alacarte-0.1.2.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page