This is a simple Django-based blog application that includes a custom history tracking system. It is designed to be easily deployable on Render.
- Blog Management: Create, edit, and delete blog posts.
- History Tracking: Automatically tracks changes (Creation, Saving, Deletion) to blog posts using Django signals.
- Deployment Ready: Pre-configured for Render.
blog/: The main blog application containing models, views, and templates.history_tracker/: A dedicated app for tracking changes to models.mysite/: Project configuration directory (settings, URLs, WSGI/ASGI).manage.py: Django's command-line utility.requirements.txt: Python dependencies.render.yaml: Configuration for deployment on Render.build.sh: Build script used by Render for environment setup.
The following diagram shows the high-level architecture of the application:
graph TD
User((User)) --> WebServer[Web Server / Gunicorn]
WebServer --> Django[Django Application]
Django --> DB[(Database / SQLite or PostgreSQL)]
Django --> Signals[Django Signals]
Signals --> HistoryTracker[History Tracker App]
HistoryTracker --> DB
The history_tracker uses Django's signal system to monitor changes in the Post model:
sequenceDiagram
participant User
participant PostModel as Post Model
participant Signals
participant Tracker as History Tracker
participant DB
User->>PostModel: Create/Update/Delete Post
PostModel->>DB: Save Changes
PostModel->>Signals: post_save / post_delete
Signals->>Tracker: Trigger Signal Handler
Tracker->>DB: Create Tracker Entry
This project includes a render.yaml file for quick deployment:
- Connect your GitHub repository to Render.
- Render will automatically detect
render.yamland set up the Web Service and Database. - The
build.shscript will:- Install dependencies.
- Run
collectstatic. - Apply migrations.
- Create a default superuser (
admin1/admin123).
Note on Render Databases: The free tier PostgreSQL databases on Render.com expire after 30 days. Once the database expires, the Django application will no longer function properly as it won't be able to connect to the database.
A working version of this application is available at: https://zacniewski.pythonanywhere.com/
This demo is hosted on PythonAnywhere, which uses SQLite3 databases. Unlike the free tier on Render, these databases do not expire, ensuring the application remains functional over time.
For more information on how to deploy Django applications on PythonAnywhere, refer to the official documentation.
- Clone the repository.
- Install dependencies:
pip install -r requirements.txt. - Run migrations:
python manage.py migrate. - Start the server:
python manage.py runserver.