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 hashes)
Built Distributions
Close
Hashes for django_alacarte-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7b2a1170375525d2284dcf5b072013e9f5c43463c89bbc27bae5582cc5ca1ee |
|
MD5 | 3160c1d7dbfc723ddd1793189f054737 |
|
BLAKE2b-256 | 47eb1e503aec380d0a1787c6d58ed558e1689028eca8825d71899a085706fee0 |
Close
Hashes for django_alacarte-0.1.5-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91e1b0e654066a172e75a280571dbf1786641e02184789735a7c747e01843263 |
|
MD5 | 5859ae59be67e6b2009860cb3dc4ce15 |
|
BLAKE2b-256 | 93743d7c477e9407cc65ef06069efdea7841bddb705d523581830814c5d59abc |