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
- Install the package:
pip install django-blog-package
Installation from Source
- Clone the repository:
git clone https://github.com/josephbraide/django-blog-package.git
cd django-blog-package
- Install the package:
pip install .
- Add to your Django project's
INSTALLED_APPS:
INSTALLED_APPS = [
# ...
'blog',
# ...
]
- Run migrations:
python manage.py migrate
- Include URLs in your project's
urls.py:
from django.urls import include, path
urlpatterns = [
# ...
path('blog/', include('blog.urls')),
# ...
]
- 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
- Access the Django admin at
/admin/ - Navigate to the Blog section
- Create categories and tags as needed
- 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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
PyPI Deployment
To deploy a new version to PyPI:
- Update the version in
setup.py - Build the package:
python setup.py sdist bdist_wheel
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_blog_package-1.0.1.tar.gz.
File metadata
- Download URL: django_blog_package-1.0.1.tar.gz
- Upload date:
- Size: 30.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb5c3a3000206d4fc41918d8b97e9964e7f1eaa02a0ab5ae69243ed72b56244e
|
|
| MD5 |
147418179869c53efe259a4d42f2d7ed
|
|
| BLAKE2b-256 |
b2effd1361104275c2bd2abd2df9539a9b82e4652d6e97581810d344ee05ba87
|
File details
Details for the file django_blog_package-1.0.1-py3-none-any.whl.
File metadata
- Download URL: django_blog_package-1.0.1-py3-none-any.whl
- Upload date:
- Size: 36.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55a89183682905d357350b3cbf915958382be770903c369e0daa254b1bd2c3ff
|
|
| MD5 |
e022775f77d52da5370d9259898f1652
|
|
| BLAKE2b-256 |
5036e6b6215a5d160dbc52498606e3838f2d112d4270b28820bd87e490f1af45
|