A powerful, elegant, and modern blog system.
DjangoBlog is a high-performance blog platform built with Python 3.10 and Django 4.0. It not only provides all the core functionalities of a traditional blog but also features a flexible plugin system, allowing you to easily extend and customize your website. Whether you are a personal blogger, a tech enthusiast, or a content creator, DjangoBlog aims to provide a stable, efficient, and easy-to-maintain environment for writing and publishing.
- Powerful Content Management: Full support for managing articles, standalone pages, categories, and tags. Comes with a powerful built-in Markdown editor with syntax highlighting.
- Full-Text Search: Integrated search engine for fast and accurate content searching.
- Interactive Comment System: Supports replies, email notifications, and Markdown formatting in comments.
- Flexible Sidebar: Customizable modules for displaying recent articles, most viewed posts, tag cloud, and more.
- Social Login: Built-in OAuth support, with integrations for Google, GitHub, Facebook, Weibo, QQ, and other major platforms.
- High-Performance Caching: Native support for Redis caching with an automatic refresh mechanism to ensure high-speed website responses.
- SEO Friendly: Basic SEO features are included, with automatic notifications to Google and Baidu upon new content publication.
- Extensible Plugin System: Extend blog functionalities by creating standalone plugins, ensuring decoupled and maintainable code. We have already implemented features like view counting and SEO optimization through plugins!
- Integrated Image Hosting: A simple, built-in image hosting feature for easy uploads and management.
- Automated Frontend: Integrated with
django-compressor
to automatically compress and optimize CSS and JavaScript files. - Robust Operations: Built-in email notifications for website exceptions and management capabilities through a WeChat Official Account.
- Backend: Python≥3.10, Django≥4.0
- Database: MySQL, SQLite (configurable)
- Cache: Redis
- Frontend: HTML5, CSS3, JavaScript
- Search: Whoosh, Elasticsearch (configurable)
- Editor: Markdown (mdeditor)
Ensure you have Python 3.10+ and MySQL/MariaDB installed on your system.
It's recommended to use a virtual environment to manage dependencies.
# Create a virtual environment named 'venv'
python -m venv venv
venv\Scripts\activate
venv\Scripts\Activate.ps1
source venv/bin/activate
Once activated, your shell prompt should show
(venv)
at the beginning.
# Clone the project to your local machine
git clone https://github.com/Rohit10jr/BlogSite.git
cd DjangoBlog
# Install dependencies
pip install -r requirements.txt
-
Database: Open
djangoblog/settings.py
, locate theDATABASES
section, and update it with your MySQL connection details.DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'djangoblog', 'USER': 'root', 'PASSWORD': 'your_password', 'HOST': '127.0.0.1', 'PORT': 3306, } }
Create the database in MySQL:
CREATE DATABASE `djangoblog` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-
More Configurations: For advanced settings such as email, OAuth, caching, and more, please refer to our Detailed Configuration Guide.
python manage.py makemigrations
python manage.py migrate
# Create a superuser account
python manage.py createsuperuser
To enable full-text search using Elasticsearch, you can run Elasticsearch inside a Docker container.
docker run -d \
--name elasticsearch7 \
-e "discovery.type=single-node" \
-e "xpack.security.enabled=false" \
-p 9207:9200 \
docker.elastic.co/elasticsearch/elasticsearch:7.17.15
curl -X GET "localhost:9207/"
python manage.py update_index
python manage.py rebuild_index
# (Optional) Generate some test data
python manage.py loaddata initial_data.json
or
python manage.py create_testdata
# (Optional) Collect and compress static files
python manage.py collectstatic --noinput
python manage.py compress --force
# Start the development server
python manage.py runserver
Now, open your browser and navigate to http://127.0.0.1:8000/
. You should see the DjangoBlog homepage!
The plugin system is a core feature of DjangoBlog. It allows you to add new functionalities to your blog without modifying the core codebase by writing standalone plugins.
- How it Works: Plugins operate by registering callback functions to predefined "hooks". For instance, when an article is rendered, the
after_article_body_get
hook is triggered, and all functions registered to this hook are executed. - Existing Plugins: Features like
view_count
andseo_optimizer
are implemented through this plugin system. - Develop Your Own Plugin: Simply create a new folder under the
plugins
directory and write yourplugin.py
. We welcome you to explore and contribute your creative ideas to the DjangoBlog community!
We warmly welcome contributions of any kind! If you have great ideas or have found a bug, please feel free to open an issue or submit a pull request.
This project is open-sourced under the MIT License.
If you find this project useful and would like to support its continued development, consider giving it a star ⭐ on GitHub or sharing it with others.
Your support motivates me to keep improving and maintaining it!
Special thanks to all open-source contributors and the tools that make this project possible.
This project is licensed under the MIT License.
You are free to use, modify, and distribute this software with proper attribution.