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

Note: You don’t need this if you use Django >= 1.7, autodiscovery is made automatically with AppConfig.

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:

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

Support

  • Django >= 1.3

  • Tested on Python 2.7 and 3.4


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.5.tar.gz (5.1 kB view details)

Uploaded Source

Built Distributions

django_alacarte-0.1.5-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

django_alacarte-0.1.5-py2-none-any.whl (7.2 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for django-alacarte-0.1.5.tar.gz
Algorithm Hash digest
SHA256 821414cb28289c282d937795f5825bdd48891e9fa129fe49253352991c396cd8
MD5 13e1dbb98203dfe6c0dea52714367dbd
BLAKE2b-256 8713ffab6766a50b528277e012ef35fce11fbbf44bf03aa21da3153eaf1af93a

See more details on using hashes here.

File details

Details for the file django_alacarte-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_alacarte-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a7b2a1170375525d2284dcf5b072013e9f5c43463c89bbc27bae5582cc5ca1ee
MD5 3160c1d7dbfc723ddd1793189f054737
BLAKE2b-256 47eb1e503aec380d0a1787c6d58ed558e1689028eca8825d71899a085706fee0

See more details on using hashes here.

File details

Details for the file django_alacarte-0.1.5-py2-none-any.whl.

File metadata

File hashes

Hashes for django_alacarte-0.1.5-py2-none-any.whl
Algorithm Hash digest
SHA256 91e1b0e654066a172e75a280571dbf1786641e02184789735a7c747e01843263
MD5 5859ae59be67e6b2009860cb3dc4ce15
BLAKE2b-256 93743d7c477e9407cc65ef06069efdea7841bddb705d523581830814c5d59abc

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