Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rafaelcanovas/django-alacarte
A minimalist Django dynamic menu app.
https://github.com/rafaelcanovas/django-alacarte
Last synced: 2 months ago
JSON representation
A minimalist Django dynamic menu app.
- Host: GitHub
- URL: https://github.com/rafaelcanovas/django-alacarte
- Owner: rafaelcanovas
- License: mit
- Created: 2014-03-15T01:56:42.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-08T03:44:57.000Z (over 7 years ago)
- Last Synced: 2024-09-16T00:29:00.586Z (4 months ago)
- Language: Python
- Homepage:
- Size: 18.6 KB
- Stars: 6
- Watchers: 6
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Alacarte
========`django-alacarte` is a minimalist menu app for Django.
## Installation
```bash
$ pip install django-alacarte
```## Usage
Add "alacarte" to your *INSTALLED_APPS*:
```python
INSTALLED_APPS = (
...,
'alacarte',
)
```In your root _urls.py_ add the following code:
```python
# ...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:
```python
import alacarteclass 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:
```django
{% 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