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.1.0.tar.gz (18.2 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.1.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_directory_cms-0.1.0.tar.gz
  • Upload date:
  • Size: 18.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 c8c106e9b1d1ec818010cc98f0729226be1c226f45ddadc57c12e4954d4336ab
MD5 ad63f60441c3d230f2a8404ca2017a43
BLAKE2b-256 f017857f22d9b06221a2386cca8616bf8950a2ff9ab395c1fe04b832212b2c0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_directory_cms-0.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_directory_cms-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 466215b21e8105d4d84bfc9fc8ab86d867e977666b9d9b768eaa8efe0d0274ad
MD5 18c295cd49c39967e7838437b14073e2
BLAKE2b-256 18f1c185dc29cd5b365dc874e4b89bc6b3eb701ae189d4e90f7ff7bfd424a270

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_directory_cms-0.1.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