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, and user management.

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:
INSTALLED_APPS = [
    # ...
    '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

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

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.0.tar.gz (29.3 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.0-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_blog_package-1.0.0.tar.gz
  • Upload date:
  • Size: 29.3 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.0.tar.gz
Algorithm Hash digest
SHA256 40ab5e08580147cc8ee53c0713074b45c18a1b4ee222dde5348bb85a512d3fdc
MD5 60ebc5ab3c35c7771424ae5fe306447b
BLAKE2b-256 d99d7ad10cc801a688b8645b5fdd6bd4b4f2ab3697126b712c03b96c1fb57dc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_blog_package-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2a52cb1462c24add87e2b79868c9e5122fd616f9dc9112104c5ce1049757e31
MD5 6fbf950248ffc1497eff60522d517b76
BLAKE2b-256 42e0c44850509797302253ea986d536e5fa0b883c00794d472eef45054c3f016

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