Skip to main content

Allows you to add and edit custom named menus similar to Wordpress menus

Project description

Django CMS Named Menus

An extension for Django CMS that allows you to create multiple menus like Wordpress

Replaces Previous Versions

This replaces the previous versions by Ryan Bagwell and Rogerio Carrasqueira which are no longer actively updated

Originally forked from:

Installation

  1. Install with pip pip install djangocms-named-menus

  2. Add cms_named_menus to INSTALLED_APPS

  3. Run migrations python manage.py migrate

Upgrading from Previous Version

  1. Uninstall previous version with pip pip uninstall -y django-cms-named-menus

  2. The migrations and code will pick up previous versions correctly.

Usage

After installation, place the {% show_named_menu 'MenuName' %} template tag where you want your menu to appear.

{% load named_cms_menu_tags %}
<ul>
  {% show_named_menu "Main Menu" %}
</ul>

Next, create your menu in the admin area using the drag and drop interface. Drag items with child menu items:

screenshot

Drag items without child menu items:

screenshot

Settings

The following settings can be changed by adding to your project's settings.py file:

  1. Override the default cache duration for Named Menus, default = 3600 seconds
CMS_NAMED_MENUS_CACHE_DURATION = 3600
  1. Set the application namespaces that can be used with Named Menus as a list, default is CMS pages only - as the page id will not be unique for other applications e.g. Aldryn NewsBlog etc. (default = ['CMSMenu',])
CMS_NAMED_MENUS_NAMESPACES = ['CMSMenu',]

or to allow ALL namespaces:

CMS_NAMED_MENUS_NAMESPACES = None
  1. Automatically remove pages that have been unpublished, deleted, or removed from Navigation (default = True)
CMS_NAMED_MENUS_REMOVE_UNAVAILABLE_PAGES = True

Testing

Install test dependencies

pip install -e ".[test]"

This installs the package in editable mode along with test dependencies:

  • djangocms-text-ckeditor
  • django-sekizai

Run tests

python -m django test tests --settings=tests.settings

For verbose output:

python -m django test tests --settings=tests.settings -v 2

Tests use an in-memory SQLite database and cover:

  • Model creation, __str__, auto-slug generation, and JSONField storage
  • unique_together constraint on (slug, site) and AutoSlugField deduplication
  • Cache utilities (flatten_menu, contains_page, key formatting)
  • Cache operations (set, get, delete, delete_many)
  • Admin helpers (get_all_available_ids, clean_menu, SimpleNode, LazyEncoder)
  • Default settings values (CACHE_DURATION, ALLOWED_NAMESPACES)
  • Signal-based cache invalidation on menu save and delete
  • Admin views (changelist, add form, change form, site-filtered listing)
  • JSONField migration verification (store/retrieve list, empty list, null)

Note: The test_filter_by_json_content test is automatically skipped on SQLite as contains lookups require PostgreSQL or MariaDB 10.2.3+.

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

djangocms_named_menus-3.0.0.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djangocms_named_menus-3.0.0-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

Details for the file djangocms_named_menus-3.0.0.tar.gz.

File metadata

  • Download URL: djangocms_named_menus-3.0.0.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for djangocms_named_menus-3.0.0.tar.gz
Algorithm Hash digest
SHA256 8e8e61d0df64c7a89aa2a5f7b6fcf7a0354a8b57ed2805fe3101ed4b1c4f53ac
MD5 98a43d7a0bd03c3e7e81f44e788b520b
BLAKE2b-256 a6858a53502881276bb311a6dd8abfb737a314a526437bd6ceb799376c20e759

See more details on using hashes here.

File details

Details for the file djangocms_named_menus-3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for djangocms_named_menus-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6da086888d5e1111bde42deba4e0a62a498599c80ea7a7372bae5d16347f139
MD5 f858c340dde14f209d2f6e378496af4d
BLAKE2b-256 76db7a6fa9307eed88781d40b745203bdb3427237538e397b2797e902fec7b4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page