lalogiadepython / django-menu-generator Goto Github PK
View Code? Open in Web Editor NEWA straightforward menu generator for Django
License: MIT License
A straightforward menu generator for Django
License: MIT License
The selected value of a root menu is overriden by _process_breadcrums. For example, if the _is_selected function correctly determines that a root menu is selected by accessing a link which contains the root's url, when _process_breadcrums is run, the selected value goes back to False.
As a workaround for this issue you can use:
{% if item.selected or item.url in request.path %} active {% endif %}
The new related_urls
feature matches too much, i.e. in the middle of a string.
Giving /car
as related URL will not only match /car/1
, but also /drinks/categories/carbonated
. Using a trailing /
would help a bit, but that would mean that /person
is not matched under all circumstances.
If you use submenus in a Django application, they are mostly collapsed if no menu item is selected. Calling a menu item from this submenu will take much longer than if it's already open (marked as selected).
Example with no selected submenu item and collapsed submenus:
Example with selected submenu item and opened submenu:
If you are directly on the page with the URL set in the menu config, the correct submenu item is selected and you can easily switch between other submenu items in the same submenu. But often you have a submenu item which is called "Persons" and shows a person list, for example. But what happens if you open a edit or details page for one person? The URL changes, so the submenu item is no longer selected, but you actually want that it's still selected.
Therefore my idea is adding an option to define a list of related URLs for every menu item. If one of these URLs is opened, the menu item will be marked then as selected, too.
Thank you for reading this slightly longer text! I would be happy to get some feedback on this idea and whether an implementation of this idea would be a benefit for this project accepted by you.
Notice: The screenshots are taken from AlekSIS, the free school information system.
Sometimes it is important to decorate a menu item with a different visual element. It is a way to indicate to the user that something need to be done through the given menu element.
For instance, a badge should be put on a menu item to indicate a necessary action to be taken by the user. But in the current implementation there is no easy way to do so. It is necessary to evaluate the menu item element in order to decorate it properly.
So, during rendering, it should be only a matter of evaluating a single menu item element in order to decide, on a template, how to decorate this menu item.
Hi,
due to lack of maintenance (see #23), there is now a fork:
https://edugit.org/AlekSIS/libs/django-menu-generator-ng
The AlekSIS tema is open to merge the projects again in the future if maintenance should improve.
Cheers and thanks for django-menu-generator,
Nik
The get_menu_from_apps function is looking for sub classes « menus ». Therefore, when following the recommandations for django 2.0+ which are to put the AppConfig class path in the INSTALLED_APPS instead of the main app class (cf https://docs.djangoproject.com/en/2.0/ref/applications/), the function does not find the MENUS dictionaries.
Ex:
The following works:
INSTALLED_APPS = [
# local apps
‘account',
The following does not work:
INSTALLED_APPS = [
# local apps
‘account.apps.AccountConfig’,
Github lists the last release as 1.0.4, but the package version is pinned at 1.0.3: https://github.com/LaLogiaDePython/django-menu-generator/blob/master/menu_generator/__init__.py
Also, the docs need to be updated. You may consider removing the changelog of the project root now that you have docs.
Currently I have a menu where I use the is_authenticated
validation of menu_generator
so I don't to ask that again in my own validator, but due the fact all validators are evaluated, an anonymous user reaches my validator and fails. Here is and example:
MENUS = {
"NAV_MENU_LEFT": [
{
"name": _("Users"),
"url": "/",
"icon_class": "fal fa-user",
"validators": [
"menu_generator.validators.is_authenticated",
("users.validators.has_user_type", "superuser"),
],
}
]
}
If several apps declare a menu item with the same name, and the item has a submenu, it would be good to merge the two menus together into one. That way, apps cann add menu entries to existing submenues.
It would also be possible to enable or disable merging with an additional attribute.
the validators are not validating with an "and" operator .
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.