A simple Django blog application demonstrating dynamic CRUD operations for posts and categories, templates, static assets, and basic admin integration. This project includes management commands to populate demo data and a small set of migrations.
- Create, Read, Update, Delete (CRUD) for blog posts
- Categories and category-based filtering
- Slugs and image URL handling for posts
- Custom management commands to populate demo categories and posts
- Templates with reusable header/footer includes and a responsive stylesheet
- Python 3.10+ / 3.11+ (tested with CPython)
- Django 4.x
- SQLite (default development DB)
- Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1On cmd.exe use:
python -m venv .venv
.\.venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtIf requirements.txt is not present, install Django:
pip install django- Apply migrations and create a superuser:
python manage.py migrate
python manage.py createsuperuser- (Optional) Populate demo data using the provided management commands:
python manage.py populate_categories
python manage.py populate_posts- Run the dev server:
python manage.py runserverOpen http://127.0.0.1:8000/ in your browser.
blog/— Django app with models, views, templates, static files, migrations, and management commandsmyapp/— Django project configuration (settings, urls, wsgi/asgi)templates/— project-level templates (404.html)db.sqlite3— development database (consider removing from repo)
- Remove compiled Python file artifacts and add a
.gitignoreto exclude__pycache__/,.venv/, anddb.sqlite3. - Don't use
db.sqlite3in production. Use PostgreSQL or another server-grade DB for deployments. - Add
requirements.txtto pin dependencies and make setup reproducible. - Secure
SECRET_KEYand other sensitive settings before deploying. Consider using environment variables.
- This app can be deployed to Heroku, PythonAnywhere, or any WSGI-capable host. Remember to set DEBUG=False and configure allowed hosts, static file handling, and the production database.
Contributions are welcome — fork the repo, create a branch, and open a PR. Please run tests and linters (if added) before submitting.
Add a license to the repository root (for example, LICENSE with MIT or Apache-2.0) to make reuse explicit.