Skip to main content

A reusable Django blog package for adding blog functionality to any Django project

Project description

Django Blog Package

A comprehensive, reusable Django blog package that can be easily installed and integrated into any Django project. This package provides a complete blogging system with standard features including post management, categories, tags, comments, user management, and enhanced rich text editing with CKEditor's full editor suite.

Features

  • Easy Installation: Simple pip installation and Django app configuration
  • Complete Blog Management: Create, edit, publish, and manage blog posts
  • Categories & Tags: Organize content with categories and flexible tagging
  • Comment System: Threaded comments with moderation capabilities
  • Search Functionality: Full-text search across posts, titles, and content
  • SEO Optimization: Automatic meta tags, clean URLs, and SEO-friendly structure
  • Admin Interface: Comprehensive Django admin integration
  • Customizable Templates: Easy template overriding and theming
  • Social Sharing: Built-in social media sharing buttons
  • Performance Optimized: Efficient queries and caching support
  • Security: Input validation, permission controls, and secure file uploads

Quick Start

Installation from PyPI

  1. Install the package:
pip install django-blog-package

Installation from Source

  1. Clone the repository:
git clone https://github.com/josephbraide/django-blog-package.git
cd django-blog-package
  1. Install the package:
pip install .
  1. Add to your Django project's INSTALLED_APPS (CKEditor must be added BEFORE the blog app):
INSTALLED_APPS = [
    # ...
    'ckeditor',
    'ckeditor_uploader',  # Optional, for file uploads
    'blog',
    # ...
]
  1. Run migrations:
python manage.py migrate
  1. Include URLs in your project's urls.py:
from django.urls import include, path

urlpatterns = [
    # ...
    path('blog/', include('blog.urls')),
    # ...
]
  1. Collect static files:
python manage.py collectstatic

CKEditor Configuration

Important: The blog package requires CKEditor configuration in your project's settings. You MUST add the following to your settings.py file:

# Media configuration (required for file uploads)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

# CKEditor configuration for blog posts
CKEDITOR_CONFIGS = {
    'blog_editor': {
        'toolbar': 'Full',
        'height': 500,
        'width': '100%',
        'extraPlugins': 'codesnippet,image2,uploadimage,find,autolink,autoembed,embedsemantic,autogrow',
        'removePlugins': 'elementspath',
        'resize_enabled': True,
        'allowedContent': True,
        'filebrowserUploadUrl': '/ckeditor/upload/',
        'filebrowserUploadMethod': 'form',
        'autoGrow_minHeight': 400,
        'autoGrow_maxHeight': 1200,
        'autoGrow_bottomSpace': 50,
        'autoGrow_onStartup': True,
        'wordcount': {
            'showParagraphs': True,
            'showWordCount': True,
            'showCharCount': True,
            'countSpacesAsChars': True,
            'countHTML': False,
        },
        'linkDefaultTarget': '_blank',
        'find_highlight': {
            'element': 'span',
            'styles': {'background-color': '#ffeb3b', 'color': '#000000'}
        },
        'scayt_autoStartup': True,
        'scayt_sLang': 'en_US',
        'scayt_maxSuggestions': 5,
        'scayt_minWordLength': 4,
    }
}

For the complete configuration including the full toolbar setup, see CKEDITOR_SETUP.md.

  1. Add CKEditor URLs to your project's urls.py:
from django.urls import path, include

urlpatterns = [
    # ... your other URL patterns
    path('ckeditor/', include('ckeditor_uploader.urls')),
]

Configuration

Basic Settings

Add the following to your settings.py for basic configuration:

# Blog settings
BLOG_SETTINGS = {
    'PAGINATE_BY': 10,
    'COMMENTS_ENABLED': True,
    'COMMENT_MODERATION': True,
    'SEARCH_ENABLED': True,
    'SOCIAL_SHARING_ENABLED': True,
    'DEFAULT_CATEGORY_SLUG': 'general',
    'EXCERPT_LENGTH': 150,
    'IMAGE_UPLOAD_PATH': 'blog/images/',
    'ALLOW_HTML_IN_COMMENTS': False,
}

URL Structure

The package provides the following URL patterns:

  • /blog/ - Blog post list
  • /blog/page/<page>/ - Paginated post list
  • /blog/search/ - Search results
  • /blog/category/<slug>/ - Posts by category
  • /blog/tag/<slug>/ - Posts by tag
  • /blog/<year>/<month>/<day>/<slug>/ - Individual post detail
  • /blog/comment/<post_id>/ - Comment submission
  • /blog/archive/ - Post archive
  • /blog/archive/<year>/ - Yearly archive
  • /blog/archive/<year>/<month>/ - Monthly archive

Usage

Creating Blog Posts

  1. Access the Django admin at /admin/
  2. Navigate to the Blog section
  3. Create categories and tags as needed
  4. Create blog posts with rich content

Template Customization

Override default templates by creating your own templates in your project's template directory:

your_project/
├── templates/
│   └── blog/
│       ├── base.html
│       ├── post_list.html
│       ├── post_detail.html
│       ├── post_archive.html
│       └── includes/
│           ├── sidebar.html
│           ├── pagination.html
│           └── comments.html

Template Tags

Use built-in template tags for common functionality:

{% load blog_tags %}

{# Get categories #}
{% get_categories as categories %}

{# Get recent posts #}
{% get_recent_posts 5 as recent_posts %}

{# Get popular tags #}
{% get_popular_tags 10 as popular_tags %}

{# Render sidebar #}
{% blog_sidebar %}

{# Render pagination #}
{% blog_pagination page_obj paginator request %}

{# Social sharing buttons #}
{% social_sharing_buttons post %}

Views and URLs

The package provides class-based views that can be extended:

from blog.views import PostListView, PostDetailView

class CustomPostListView(PostListView):
    template_name = 'myapp/post_list.html'
    paginate_by = 15

class CustomPostDetailView(PostDetailView):
    template_name = 'myapp/post_detail.html'

Models

Core Models

  • Category: Hierarchical organization of posts
  • Tag: Flexible categorization through many-to-many relationships
  • Post: Core content with publication workflow
  • Comment: User engagement with moderation system

Example Usage

from blog.models import Post, Category, Tag

# Get published posts
published_posts = Post.objects.published()

# Get posts by category
tech_posts = Post.objects.by_category('technology')

# Get posts by tag
python_posts = Post.objects.by_tag('python')

# Get recent posts
recent_posts = Post.objects.recent(5)

Admin Interface

The package provides a comprehensive admin interface with:

  • Post management with bulk actions
  • Category and tag management
  • Comment moderation tools
  • Publication workflow management
  • Search and filtering capabilities

Testing

Run the test suite:

python manage.py test blog

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

PyPI Deployment

To deploy a new version to PyPI:

  1. Update the version in setup.py
  2. Build the package:
python setup.py sdist bdist_wheel
  1. Upload to PyPI:
twine upload dist/*

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For issues and questions:

  • Create an issue on GitHub
  • Check the documentation
  • Review the code examples

Dependencies

  • Django >= 4.2, < 5.0
  • Pillow >= 9.0, < 11.0
  • django-ckeditor >= 6.0, < 7.0 (for rich text editing)

CKEditor Support

This package includes full CKEditor integration for rich text editing:

  • Rich Text Content: Blog posts use CKEditor's RichTextField
  • Admin Integration: CKEditor widgets automatically configured in Django admin
  • File Uploads: Support for image and file uploads (when configured)
  • Document Search & Replace: Find (Ctrl+F) and replace text throughout documents
  • Spell Checking: Real-time spell checking as you type
  • Auto-Grow Editor: Editor expands automatically with content
  • Advanced Formatting: Tables, fonts, colors, and special characters

For detailed CKEditor setup and configuration, see CKEDITOR_SETUP.md.

Troubleshooting: If you encounter "No configuration named 'blog_editor' found" errors, ensure:

  1. ckeditor is in INSTALLED_APPS before blog
  2. CKEDITOR_CONFIGS with blog_editor configuration is added to your settings.py
  3. MEDIA_URL and MEDIA_ROOT are configured
  4. CKEditor URLs are added to your urls.py

Compatibility

  • Python 3.8+
  • Django 4.2+
  • SQLite, PostgreSQL, MySQL databases

Roadmap

  • RSS/Atom feeds
  • Email notifications
  • Advanced search with Elasticsearch
  • Multi-language support
  • Image galleries
  • Newsletter integration
  • Analytics integration
  • API endpoints
  • GraphQL support

Django Blog Package - Making blogging in Django projects simple and powerful.

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_blog_package-1.0.3.tar.gz (44.6 kB view details)

Uploaded Source

Built Distribution

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

django_blog_package-1.0.3-py3-none-any.whl (55.4 kB view details)

Uploaded Python 3

File details

Details for the file django_blog_package-1.0.3.tar.gz.

File metadata

  • Download URL: django_blog_package-1.0.3.tar.gz
  • Upload date:
  • Size: 44.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for django_blog_package-1.0.3.tar.gz
Algorithm Hash digest
SHA256 2c270660f40935416177702e7bc191310fdba540dc99f32bc2ebfc96582d9079
MD5 60f8db654e5935674dd27db9f0f26bed
BLAKE2b-256 4a0413b4a6cc18870f48aa8c6f4fe9a7dd1a474d06460aa396675d1e3623f90c

See more details on using hashes here.

File details

Details for the file django_blog_package-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for django_blog_package-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 99f1d13863b01ff2fa2a962ad77b77dcde963a5fc614dfba41d0bcdad4d0528c
MD5 7398529b1d735c8583152fb95822a895
BLAKE2b-256 5e1bd2ce3c64f3998a5446df65a66f525ce85aecf76c1c1025421dc4678a5029

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