jphalip / django-treemenus Goto Github PK
View Code? Open in Web Editor NEWA simple django app to manage navigation menus via the django admin
License: BSD 3-Clause "New" or "Revised" License
A simple django app to manage navigation menus via the django admin
License: BSD 3-Clause "New" or "Revised" License
Both will be great for SMB clients. Any thoughts?
Please review the MANUAL.txt.
Outdated content:
I had the same issue in #13
I downloaded the latest update today with the fixes (jphalip-django-treemenus-4ed8ad9)
I added the template files as per the packaged documentation (I had some errors due to the online documentation's inaccurate/out of date instructions for coding of the menu template files.)
The site displays without errors (its on a development local machine) but I don't see the tree menus.
If I change the menu name in my template file, I get an error (error: Menu matching query does not exist) and when I enter the correct menu name, the site displays without errors but there is no menu displayed and there is no html mark up for the menus (when the page is viewed through firebug.)
(I only started using Django a couple of days back so I'm afraid I can't look deeper/diagnose the issue deeper.)
Hi! Sorry if it's a dummy question, but I can't use "related_lookup_fields" of grappelli with treemenus.
When I click on magnify icon the pop-up uses a wrong url.
Screenshots of an example:
http://awesomescreenshot.com/0fazpaia0
Sends to http://localhost:8000/admin/treemenus/menu/engine/article/?t=id&pop=1 but the correct link would be http://localhost:8000/admin/engine/article/?t=id&pop=1
Thx!
Regards,
Max
I get the following error on Django 1.7.6 (python 3) after installing with pip.
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/treemenus/menu/add/
Django Version: 1.7.6
Python Version: 3.4.1
Installed Applications:
('suit',
'adminsortable',
'modeltranslation',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sitemaps',
'promo',
'taggit',
'rosetta',
'embed_video',
'treemenus',
'relatedwidget',
'inplaceeditform')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Template error:
In template /Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/suit/templates/admin/change_form.html, error at line 128
'MenuAdmin' object has no attribute '__name__'
118 : </ul>
119 : {% endif %}{% endif %}
120 : {% endblock %}
121 :
122 : {% block sidebar %}{% endblock %}
123 :
124 : </div>
125 : <div class="inner-center-column">
126 : {% csrf_token %}{% block form_top %}{% endblock %}
127 : {% block suit_form_tabs %}
128 : {% if adminform.model_admin.suit_form_tabs %}
129 : <ul id="suit_form_tabs" class="nav nav-tabs nav-tabs-suit" data-tab-prefix="suit-tab">
130 : {% for tab in adminform.model_admin.suit_form_tabs %}
131 : <li><a href="#{{ tab.0 }}">{{ tab.1 }}</a></li>{% endfor %}
132 : </ul>
133 : {% endif %}
134 : {% endblock %}
135 : <div class="tab-content tab-content-main">
136 : {% if is_popup %}
137 : <input type="hidden" name="_popup" value="1"/>{% endif %}
138 : {% if errors %}
Traceback:
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
137. response = response.render()
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/response.py" in render
103. self.content = self.rendered_content
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/response.py" in rendered_content
80. content = template.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
148. return self._render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/loader_tags.py" in render
65. result = block.nodelist.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/defaulttags.py" in render
305. match = condition.eval(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/defaulttags.py" in eval
898. return self.value.resolve(context, ignore_failures=True)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in resolve
596. obj = self.var.resolve(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in resolve
734. value = self._resolve_lookup(context)
File "/Users/nonni/Code/beta-test/venv/lib/python3.4/site-packages/django/template/base.py" in _resolve_lookup
791. getcallargs(current)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/inspect.py" in getcallargs
1167. f_name = func.__name__
Exception Type: AttributeError at /admin/treemenus/menu/add/
Exception Value: 'MenuAdmin' object has no attribute '__name__'
Hi,
Thank you for your work. I tried to use it with django 1.8 and there is a small compatibility problem.
In treemenus/templatetags/tree_menu_tags at line 63 you wrote from django.template import TOKEN_BLOCK, Token while in django 1.8 you need to import from django.template.base.
I think you may consider to update the code.
Again, thank you very much
Best regards,
Luca
Hi,
i'm trying to setup django-treemenus with multiple databases. Users choose database to connect when they log in. I modified tree_menu_tags.py and put using('db') in show_menu
menu = Menu.objects.using('db').get(name=menu_name) but it doesn't return menu_item
Hi,
Trying to delete an item makes it redirect to homepage, as it says in admin.py.
Running off "commit 4c136a4"
Changed:
--- a/treemenus/admin.py
+++ b/treemenus/admin.py
@@ -115,7 +115,7 @@ class MenuAdmin(admin.ModelAdmin):
url(r'^item_changelist/$', RedirectView.as_view(url='/'), name='treemenus_menuitem_changelist'),
url(r'^item_add/$', RedirectView.as_view(url='/'), name='treemenus_menuitem_add'),
url(r'^item_history/(?P<pk>[-\w]+)/$', RedirectView.as_view(url='/'), name='treemenus_menuitem_history'),
- url(r'^item_delete/(?P<pk>[-\w]+)/$', RedirectView.as_view(url='/'), name='treemenus_menuitem_delete'),
+ url(r'^item_delete/(?P<menu_item_pk>[-\w]+)/$', self.admin_site.admin_view(self.delete_menu_item), name='treemenus_m
)
return my_urls + urls
@@ -146,8 +146,10 @@ class MenuAdmin(admin.ModelAdmin):
menu_item_admin = self.menu_item_admin_class(MenuItem, self.admin_site, menu)
return menu_item_admin.change_view(request, menu_item_pk, extra_context={'menu': menu})
- def delete_menu_item(self, request, menu_pk, menu_item_pk):
+ def delete_menu_item(self, request, menu_pk=None, menu_item_pk=None):
''' Custom view '''
+ if not menu_pk:
+ menu_pk = MenuItem.objects.select_related('menu').get(id=menu_item_pk).menu.id
menu = self.get_object_with_change_permissions(request, Menu, menu_pk)
menu_item_admin = self.menu_item_admin_class(MenuItem, self.admin_site, menu)
hi,
I'm using the github-version of treemenus in my django project and want to run the tests in context of the project. to make it short: it doesn't work. long story:
1st. not having added "treemenus.tests.fake_menu_extension", to the installed_apps I get:
Error: Database test_bb couldn't be flushed. Possible reasons:
- The database isn't running or isn't configured correctly.
- At least one of the expected database tables doesn't exist.
- The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command
wasn't able to run.
The full error: (1146, "Table 'test_bb.fake_menu_extension_fakemenuitemextension'
doesn't exist")
twice. so I actually add "treemenus.tests.fake_menu_extension", to my installed apps, which leads to the 2nd situation:
2nd. I'm using custom templates using the url-tag referring to some urls of my project. the problem is, obviously you are using your own testing-urls and you are modifying the settings at runtime. so my tests don't pass but give me errors like:
TemplateSyntaxError: Caught NoReverseMatch while rendering:
Reverse for 'home' with arguments '()' and keyword arguments '{}' not found.
solution: please use the setup's test_suite option, as seen in http://github.com/alex/django-taggit/blob/master/setup.py for example.
The show_menu template tag performs Menu.objects.get(...). If the database is not populated (for example, when running tests), any view referencing a template with this templatetag (which is usually at base template, affecting all pages!) will raise DoesNotExist.
Shouldn't the menu fail gracefully by not showing anything (just like django's own templatetags) instead of allowing this exception?
i'm using pip to manage dependencies for my project.
it seems like setup.py for django-treemenus 0.8.6 reports its version as 0.8.5, and that setup.py for version 0.8.7 reports its version as 0.8.7-pre.
if i list "django-treemenus==0.8.7" in a requirements file and do "pip install -r requirements.txt". i get the error "Source in [...]/build/django-treemenus has version 0.8.7-pre that conflicts with django-treemenus==0.8.7 (from -r requirements.txt (line 1))"
if i change the requirement to "django-treemenus==0.8.7-pre", i get "No distributions matching the version for django-treemenus==0.8.7-pre (from -r requirements.txt (line 1))"
any chance you could change your version numbers or PyPi index so that they correspond to each other?
In admin, arrow-down and arrow-up images do not appear.
$ grep -R "arrow-down" eggs/django_grappelli-2.3.3-py2.7.egg/
eggs/django_grappelli-2.3.3-py2.7.egg/EGG-INFO/SOURCES.txt:grappelli/static/grappelli/img/icons/icon-tools-arrow-down-handler-hover.png
eggs/django_grappelli-2.3.3-py2.7.egg/EGG-INFO/SOURCES.txt:grappelli/static/grappelli/img/icons/icon-tools-arrow-down-handler.png
eggs/django_grappelli-2.3.3-py2.7.egg/grappelli/static/grappelli/css/tools.css:.tools a.arrow-down-handler:link, .tools a.arrow-down-handler:visited {
eggs/django_grappelli-2.3.3-py2.7.egg/grappelli/static/grappelli/css/tools.css: background-image: url('../img/icons/icon-tools-arrow-down-handler.png');
eggs/django_grappelli-2.3.3-py2.7.egg/grappelli/static/grappelli/css/tools.css:.tools a.arrow-down-handler:hover, .tools a.arrow-down-handler:active {
eggs/django_grappelli-2.3.3-py2.7.egg/grappelli/static/grappelli/css/tools.css: background-image: url('../img/icons/icon-tools-arrow-down-handler-hover.png');
$ grep -R "arrow-down" eggs/django_treemenus-0.8.7_pre-py2.7.egg/
eggs/django_treemenus-0.8.7_pre-py2.7.egg/treemenus/templates/admin/treemenus/menu/change_form.html:
hi,
I'm using django-treemenus in a project. I've got 'treemenus', 'treemenus.tests' and 'tremenus.tests.fake_menu_extension' in my INSTALLED_APPS. when running the tests, I receive 11 errors for 11 tests, mostly because
ImportError: No module named fake_menu_extension
how do I have to configure my project to test your app correctly?
Any thought about using django-mptt to manage the underlaying trees?
This app is not compatible with 1.9 Django. Some forks fixed it. Let's choose next maintainer for this package, who will create next create official pip versions for django-treemenus, fix README here and put link on top to another repository...
https://github.com/jphalip/django-treemenus/network
@jphalip what do you think about it?..
When i run my django app using the development server everything is working just fine.
On my production server i ran the app under apache mod_wsgi and i get the following error randomly ( not every time ).
Django Version: 1.3
Exception Type: TemplateSyntaxError
Exception Value:
Caught AttributeError while rendering: 'NoneType' object has no attribute 'objects'
Exception Location: /home/django/ysma.grve/lib/python2.5/site-packages/django_treemenus-0.8.7_pre-py2.5.egg/treemenus/models.py in children, line 99
Python Executable: /usr/bin/python
Python Version: 2.5.2
Python Path:
['/var/www/vhosts/orbitlab.gr/subdomains/ysma/httpdocs/',
'/home/django/ysma.grve/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/Django-1.3-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/django_localeurl-1.4-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/django_reversetag-0.3.2-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/South-0.7.3-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/MySQL_python-1.2.3-py2.5-linux-x86_64.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/django_tinymce-1.5.1a2-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/django_treemenus-0.8.7_pre-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/PIL-1.1.7-py2.5-linux-x86_64.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/sorl_thumbnail-11.05.2-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/python_memcached-1.47-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/django_haystack-1.2.4-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages/django_modeltranslation-0.3.2-py2.5.egg',
'/home/django/ysma.grve/lib/python2.5/site-packages',
'/usr/lib/python2.5',
'/usr/lib/python2.5/plat-linux2',
'/usr/lib/python2.5/lib-tk',
'/usr/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages',
'/var/lib/python-support/python2.5',
'/home/django/ysma.grve/bin']
Server time: Tue, 9 Aug 2011 13:12:42 +0300
Template error
In template /var/www/vhosts/orbitlab.gr/subdomains/ysma/httpdocs/ysmaWebsite/templates/treemenus/menu.html, error at line 2
Caught AttributeError while rendering: 'NoneType' object has no attribute 'objects'
1 {% load tree_menu_tags %}
2 {% for menu_item in menu.root_item.children %}
3 {% show_menu_item menu_item %}
4 {% endfor %}
5
Hello,
named urls does not seem to work.
when pointing to via 'kunden_detail', the generated href is empty...
url(r'^kunden/detail/$', 'abc.views.kunden_detail', name='kunden_detail'),
Thx
Hi! It would nice to see its look and feel of this tree representation. Thank you!
Hi, if yes please put in the description is deprecated please!
So many people would not bother to try it
Thank
On Django 1.4 I've seen this problem. Could you give me some help?
Thanks,
Jan
Environment:
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.markup',
'elevenbits.blog',
'elevenbits.static',
'elevenbits',
'treemenus',
'tracking')
Installed Middleware:
('tracking.middleware.BannedIPMiddleware',
'django.middleware.gzip.GZipMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'tracking.middleware.VisitorTrackingMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
response = middleware_method(request)
if not visitor.last_update or visitor.last_update <= one_hour_ago:
Exception Type: TypeError at /
Exception Value: can't compare offset-naive and offset-aware datetimes
Hi,
I was trying to get treemenus to create an expanding menu effect, where the children of the current page get expanded, but not other sections. (e.g. http://ukwindsurfing.com/information/regions/). NB: I'm not a programmer as such, so I may have missed a point or two.
I've got it working, as it's a similar problem to highlighting the current page. However, it's much easier with a couple of additions to the menu item model:
def this_section(self):
url_part = self.url
list_of_sections = url_part.split("/")
section = list_of_sections[-2]
return section
def matching_url(self):
return "^" + self.url + "$"
Combined with the code from 'Automatically select menu items' section you can use this in the templates:
{% load tree_menu_tags %}
{% if menu_item.has_children %}
<li>{% if menu_item.matching_url|match_path:request.path %}<strong class="nolink">{{ menu_item.caption }}</strong>{% else %}
<a href="{{ menu_item.url }}">{{ menu_item.caption }}</a>{% endif %}
{% if menu_item.this_section in request.path %}
<ul>
{% for child in menu_item.children %}
{% show_menu_item child %}
{% endfor %}
</ul>{% endif %}
</li>{% else %}
<li>{% if menu_item.matching_url|match_path:request.path %}<strong class="nolink">{{ menu_item.caption }}</strong>{% else %}
<a href="{{ menu_item.url }}">{{ menu_item.caption }} </a>{% endif %}</li>{% endif %}
I know you've outlined extension methods, but as someone with limited programming experience,
it seems a lot simpler to make a couple of additions to the model (and the match_path addition to the template tags).
Could those be included by default?
I've created a patch if that helps, which is my first foray into Git.
in django 2 it's not working
Is it Python 3 compatible?..
It looks like Changeset 16857 has broken the app. I get a "Reverse for 'treemenus_menuitem_changelist' with arguments '()' and keyword arguments '{}' not found." when adding a menu item.
Encountered following issues when installing tremens in a 1.9.4 site:
in admin.py, importing from django.contrib.admin.util fails. In 1.9.4. this package is django.contrib.admin.utils.
In addition, added AppConfig to apps.py and to init to be compliant with latests changes.
See below GIT file for suggested changes, works for me on 1.9.4. Not tested against older versions.
Cheers
Ernst
I've had a very strange issue with using treemenus in production. It was all going swimmingly well, working great on my local setup with the django-server, but when I moved to the live site it basically disappeared.
On the front-end the templates cause no error, but the output simply does not appear. (I had done a dump-data import-data to get the local menus onto the live site, there should have been something there.)
In the admin section, the menu page would appear fine, but in the change-menu page is blank after the name. The rest of the admin template loads ok, but it's just blank in the middle.
Is treemenu doing anything that Nginx might not like? It is the usual mod_wsgi setup, I haven't had any similar issues with other apps, and I'm a bit stumped as to how to de-bug it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.