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.

Source Distribution

django-alacarte-0.1.2.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file django-alacarte-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django-alacarte-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3e1bcc6293943335c0807ce91f8bafc4a10b492813789ac17b1fa2fcce4b3967
MD5 58aa23d626fee5ff402683d5bbc4d83f
BLAKE2b-256 3db0f73c6ff46b7fbfbe97a77315cc9228689da16958a823d3813b8068cf7e85

See more details on using hashes here.

Supported by

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