Skip to main content

Reusable Django CMS package with SEO-optimized pages and hierarchical menus

Project description

Django Directory CMS

A reusable Django CMS package providing SEO-optimized pages and hierarchical menus with Bootstrap Icons support.

Features

  • Pages App: Highly SEO-optimized static pages with:

    • 16 SEO fields (title, meta description, OG tags, Twitter cards, schema.org)
    • Automatic slug generation with collision handling
    • Integration with django-seo-audit for SEO scoring
    • Publishing controls (active, published status)
  • Menus App: Hierarchical navigation menus with:

    • Parent/child relationships for dropdown menus
    • Bootstrap Icons integration (42 curated icons)
    • Page linking with automatic URL updates
    • Custom URL support for external links
    • Order control and visibility settings
    • Global context processor for site-wide access

Installation

pip install django-directory-cms

Quick Start

1. Add to INSTALLED_APPS

# settings.py
INSTALLED_APPS = [
    # ...
    "django_directory_cms.pages",
    "django_directory_cms.menus",
    # Required dependency
    "django_seo_audit",
]

2. Add Context Processor

# settings.py
TEMPLATES = [
    {
        "OPTIONS": {
            "context_processors": [
                # ...
                "django_directory_cms.menus.context_processors.menu_items",
            ],
        },
    },
]

3. Run Migrations

python manage.py migrate django_directory_cms_pages
python manage.py migrate django_directory_cms_menus

4. Include URLs

# urls.py
from django.urls import include, path

urlpatterns = [
    # ...
    path("pages/", include("django_directory_cms.pages.urls")),
]

Usage

Creating Pages

Pages can be created via Django admin or programmatically:

from django_directory_cms.pages.models import Page

page = Page.objects.create(
    title="About Us",
    content="<p>Welcome to our site!</p>",
    seo_title="About Our Company",
    meta_description="Learn more about our mission and values",
    is_published=True,
)

# Access SEO methods from django-seo-audit mixin
print(page.get_seo_title())  # "About Our Company"
print(page.get_absolute_url())  # "/pages/about-us/"

Creating Menus

Menu items can link to pages or custom URLs:

from django_directory_cms.menus.models import MenuItem

# Link to a page
menu_item = MenuItem.objects.create(
    title="About",
    anchor_text="About",
    page=page,
    icon_class="bi-info-circle",
    order=1,
)

# Custom external link
external_link = MenuItem.objects.create(
    title="Documentation",
    anchor_text="Docs",
    url="https://docs.example.com",
    icon_class="bi-book",
    is_external=True,
    order=2,
)

# Hierarchical menu
parent = MenuItem.objects.create(
    title="Resources",
    anchor_text="Resources",
    url="/resources/",
    order=3,
)

child = MenuItem.objects.create(
    title="Blog",
    anchor_text="Blog",
    url="/blog/",
    parent=parent,
    order=1,
)

Templates

Access menus in templates via context processor:

<!-- Menu items are available globally as `menu_items` -->
<nav>
  <ul>
    {% for item in menu_items %}
      <li>
        <a href="{{ item.get_url }}" {% if item.is_external %}target="_blank"{% endif %}>
          {% if item.display_icon %}<i class="{{ item.display_icon }}"></i>{% endif %}
          {{ item.anchor_text }}
        </a>
        {% if item.menu_children %}
          <ul>
            {% for child in item.menu_children %}
              <li><a href="{{ child.get_url }}">{{ child.anchor_text }}</a></li>
            {% endfor %}
          </ul>
        {% endif %}
      </li>
    {% endfor %}
  </ul>
</nav>

Requirements

  • Python 3.12+
  • Django 4.2+
  • django-seo-audit 0.2.0+
  • Pillow 10.0.0+ (for image fields)

License

MIT License - see LICENSE file for details.

Credits

Built by the Directory Platform team.

Links

Development

See CLAUDE.md for development guidelines and architecture documentation.

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

django_directory_cms-0.2.0.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

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

django_directory_cms-0.2.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file django_directory_cms-0.2.0.tar.gz.

File metadata

  • Download URL: django_directory_cms-0.2.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_directory_cms-0.2.0.tar.gz
Algorithm Hash digest
SHA256 bc98476b4eb9f9b50850b01614d4859e094c614d6aa615173ea9096c14c303bc
MD5 09a845add4877adc2a4c9a8792d60204
BLAKE2b-256 72b2e4618d1e32b00f0c7e30080c12ff3a5eab344551e6444e73d72c1acf0e74

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_directory_cms-0.2.0.tar.gz:

Publisher: publish.yml on heysamtexas/django-directory-cms

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_directory_cms-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_directory_cms-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 03155ea411848198249ba4b2aa2ca9fa6c25ae5f3a3b2e1724bef44703e1cfbb
MD5 20a652a6efaa9f5d88b79302dffd10b7
BLAKE2b-256 b33bdf359c1f7b7fc15fb25ea4f97ae7ce1ca204e5a14c012102cce4cd44ec69

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_directory_cms-0.2.0-py3-none-any.whl:

Publisher: publish.yml on heysamtexas/django-directory-cms

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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