1
- Django Menu Generator
2
- ====================
3
-
4
- ** A menu generating application for Django**
1
+ # Django Menu Generator
2
+ > A menu generating application for Django
5
3
6
4
[ ![ status-image]] [ status-link ]
7
5
[ ![ version-image]] [ version-link ]
8
6
[ ![ coverage-image]] [ coverage-link ]
9
7
10
- Overview
11
- ====================
12
-
13
- Generates ** Simple Navigation** for Django projects/apps, while keeping it ** DRY** .
14
-
15
- How to install
16
- ====================
17
-
18
- 2. pip install django-menu-generator
19
- 3. git clone http://github.com/un33k/django-menu-generator
20
- a. cd django-menu-generator
21
- b. run python setup.py
22
- 4. wget https://github.com/un33k/django-menu-generator/zipball/master
23
- a. unzip the downloaded file
24
- b. cd into django-menu-generator-* directory
25
- c. run python setup.py
26
-
27
- How to use
28
- ====================
29
- 1. Install `django-menu-generator` as per the above instructions.
30
- 2. Add `menu-generator` to your `INSTALLED_APPS`.
31
- 3. Add `{% load menu-generator %}` to templates that require it.
32
-
33
- ``` python
34
- # ###################################################################################
35
- Example: settings.py
36
- # ###################################################################################
37
-
38
- NAV_MENU_LEFT = [
39
- {
40
- " name" : " Home" ,
41
- " url" : " /" ,
42
- },
43
- {
44
- " name" : " About" ,
45
- " url" : " /about" ,
46
- },
47
- ]
48
-
49
- NAV_MENU_RIGHT = [
50
- {
51
- " name" : " Login" ,
52
- " url" : " login_url_view" , # reversible
53
- " validators" : [" menu_generator.validators.is_anonymous" ],
54
- },
55
- {
56
- " name" : " Register" ,
57
- " url" : " register_view_url" , # reversible
58
- " validators" : [" menu_generator.validators.is_anonymous" ],
59
- },
60
- {
61
- " name" : " Account" ,
62
- " url" : " /acount" ,
63
- " validators" : [" menu_generator.validators.is_authenticated" ],
64
- " submenu" : [
65
- {
66
- " name" : " Profile" ,
67
- " url" : " /account/profile" ,
68
- },
69
- {
70
- " name" : " Account Balance" ,
71
- " url" : " /account/balance" ,
72
- " validators" : [" myapp.profiles.is_paid_user" ],
73
- },
74
- {
75
- " name" : " Account Secrets" ,
76
- " url" : " /account/secrets" ,
77
- " validators" : [" menu_generator.validators.is_superuser" ],
78
- }
79
- ],
80
- },
81
- ]
82
-
83
- FOOTER_MENU_LEFT = [
84
- {
85
- " name" : " Facebook" ,
86
- " url" : " facebook.com/foobar" ,
87
- },
88
- {
89
- " name" : " Contact US" ,
90
- " url" : " /contact" ,
91
- },
92
- ]
93
-
94
- FOOTER_MENU_RIGHT = [
95
- {
96
- " name" : " Address" ,
97
- " url" : " /address" ,
98
- },
99
- ]
100
- ```
8
+ A productivity tool that enables the generation of full featured menus through python list dictionaries, you only need to setup the HTML structure once for each menu you like to build and then use the dictionaries to generate menu items
9
+
10
+ ## Features:
11
+
12
+ - Tested support to Python 2.7, 3.4, 3.5, 3.6
13
+ - Tested support to Django 1.8.18, 1.9.13, 1.10.7, 1.11
14
+ - No database
15
+ - Support unlimited menus
16
+ - Icons support
17
+ - Semi-Automatically identifies the selected item and his breadcrums
18
+ - Controls view access through validators (Permissions, Authentications or whatever you want)
19
+
20
+ ## Installation:
21
+
22
+ You can install it with one of these options:
23
+ - easy_install django-menu-generator
24
+ - pip install django-menu-generator
25
+ - git clone http://github.com/un33k/django-menu-generator
26
+ a. cd django-menu-generator
27
+ b. run python setup.py
28
+ - wget https://github.com/un33k/django-menu-generator/zipball/master
29
+ a. unzip the downloaded file
30
+ b. cd into django-menu-generator-* directory
31
+ c. run python setup.py
32
+
33
+ ## Usage:
34
+
35
+ 1 . Install 'django-menu-generator' as per the above instructions.
36
+ 2 . Add 'menu_generator' to your INSTALLED_APPS.
37
+ 3 . Add {% load menu_generator %} to templates that will handle the menus.
38
+
39
+ ``` python
40
+ # ###################################################################################
41
+ Example: settings.py
42
+ # ###################################################################################
43
+
44
+ NAV_MENU_LEFT = [
45
+ {
46
+ " name" : " Home" ,
47
+ " url" : " /" ,
48
+ },
49
+ {
50
+ " name" : " About" ,
51
+ " url" : " /about" ,
52
+ },
53
+ ]
54
+
55
+ NAV_MENU_RIGHT = [
56
+ {
57
+ " name" : " Login" ,
58
+ " url" : " login_url_view" , # reversible
59
+ " validators" : [" menu_generator.validators.is_anonymous" ],
60
+ },
61
+ {
62
+ " name" : " Register" ,
63
+ " url" : " register_view_url" , # reversible
64
+ " validators" : [" menu_generator.validators.is_anonymous" ],
65
+ },
66
+ {
67
+ " name" : " Account" ,
68
+ " url" : " /acount" ,
69
+ " validators" : [" menu_generator.validators.is_authenticated" ],
70
+ " submenu" : [
71
+ {
72
+ " name" : " Profile" ,
73
+ " url" : " /account/profile" ,
74
+ },
75
+ {
76
+ " name" : " Account Balance" ,
77
+ " url" : " /account/balance" ,
78
+ " validators" : [" myapp.profiles.is_paid_user" ],
79
+ },
80
+ {
81
+ " name" : " Account Secrets" ,
82
+ " url" : " /account/secrets" ,
83
+ " validators" : [" menu_generator.validators.is_superuser" ],
84
+ }
85
+ ],
86
+ },
87
+ ]
88
+
89
+ FOOTER_MENU_LEFT = [
90
+ {
91
+ " name" : " Facebook" ,
92
+ " url" : " facebook.com/foobar" ,
93
+ },
94
+ {
95
+ " name" : " Contact US" ,
96
+ " url" : " /contact" ,
97
+ },
98
+ ]
99
+
100
+ FOOTER_MENU_RIGHT = [
101
+ {
102
+ " name" : " Address" ,
103
+ " url" : " /address" ,
104
+ },
105
+ ]
106
+ ```
107
+
108
+ You can build the menu list dictionaries inside the project apps with `` menus.py `` files, see the docs for more.
101
109
102
110
Then in your template, load the template tag to generate your menu.
103
111
@@ -107,20 +115,20 @@ Then in your template, load the template tag to generate your menu.
107
115
108
116
<!DOCTYPE html>
109
117
<html >
110
- <head ><title >Django Menuware </title ></head >
118
+ <head ><title >Django Menu Generator </title ></head >
111
119
<body >
112
120
<!-- NAV BAR Start -->
113
121
{% get_menu "NAV_MENU_LEFT" as left_menu %}
114
122
<div style =" float :left ;" >
115
123
{% for item in left_menu %}
116
124
<li class =" {% if item.selected %} active {% endif %}" >
117
- < a href =" {{item.url }}" >{{ item.name}}</a >
125
+ < a href = " {{ item.url }} " > < i class =" {{ item.icon_class }}" ></ i > {{ item.name }}</a >
118
126
</li >
119
127
{% if item.submenu %}
120
128
<ul >
121
129
{% for menu in item.submenu %}
122
130
<li class =" {% if menu.selected %} active {% endif %}" >
123
- <a href =" {{menu.url}}" >{{menu.name}}</a >
131
+ <a href =" {{ menu.url }}" >{{ menu.name }}</a >
124
132
</li >
125
133
{% endfor %}
126
134
</ul >
@@ -132,13 +140,13 @@ Then in your template, load the template tag to generate your menu.
132
140
<div style =" float :right ;" >
133
141
{% for item in right_menu %}
134
142
<li class =" {% if item.selected %} active {% endif %}" >
135
- <a href =" {{item.url}}" >{{item.name}}</a >
143
+ <a href =" {{ item.url }}" >{{ item.name }}</a >
136
144
</li >
137
145
{% if item.submenu %}
138
146
<ul >
139
147
{% for menu in item.submenu %}
140
148
<li class =" {% if menu.selected %} active {% endif %}" >
141
- <a href =" {{menu.url}}" >{{menu.name}}</a >
149
+ <a href =" {{ menu.url }}" >{{ menu.name }}</a >
142
150
</li >
143
151
{% endfor %}
144
152
</ul >
@@ -162,27 +170,27 @@ Then in your template, load the template tag to generate your menu.
162
170
</html >
163
171
```
164
172
165
- Running the tests
166
- ====================
173
+ ## Running the tests:
167
174
168
175
To run the tests against the current environment:
169
176
170
177
python manage.py test
171
178
172
179
173
- License
174
- ====================
180
+ ## License:
175
181
176
182
Released under a ([ MIT] ( LICENSE ) ) license.
177
183
184
+ ## Author and mantainers:
185
+
186
+ [ Milton Lenis
] ( https://github.com/MiltonLn ) -
[email protected]
187
+
188
+ ## Credits:
189
+
190
+ I'd like to thank [ Val Kneeman] [ valkneeman-link ] , the original author of this project under the name 'menuware'
191
+ https://github.com/un33k/django-menuware
178
192
179
- Version
180
- ====================
181
- X.Y.Z Version
182
193
183
- `MAJOR` version -- when you make incompatible API changes,
184
- `MINOR` version -- when you add functionality in a backwards-compatible manner, and
185
- `PATCH` version -- when you make backwards-compatible bug fixes.
186
194
187
195
[ status-image ] : https://travis-ci.org/RADYConsultores/django-menu-generator.svg?branch=master
188
196
[ status-link ] : https://travis-ci.org/RADYConsultores/django-menu-generator?branch=master
@@ -196,3 +204,5 @@ X.Y.Z Version
196
204
[ download-image ] : https://img.shields.io/pypi/dm/django-menu-generator.svg
197
205
[ download-link ] : https://pypi.python.org/pypi/django-menu-generator
198
206
207
+ [ valkneeman-link ] : https://github.com/un33k
208
+
0 commit comments