A simple blog project built with Django and Tailwind CSS.
- Blog posts with images and captions
- Author profiles
- Contact form
- User authentication
This project uses two different databases depending on the environment:
| Environment | Database | Location |
|---|---|---|
| Development (local) | SQLite | db.sqlite3 in the project root |
| Production (Render) | PostgreSQL | Managed by Render, configured via DATABASE_URL env var |
No. The local db.sqlite3 file is included in the repository and already contains sample/seed data:
| Table | Records |
|---|---|
blog_post |
4 posts |
auth_user |
2 users |
blog_authorprofile |
2 profiles |
blog_tag |
1 tag |
blog_message |
1 contact message |
You can run python manage.py migrate followed by python manage.py runserver and the blog will already have content without any manual data entry.
The production PostgreSQL database starts empty after deployment. Use the Data Migration steps in the Deployment section to copy data from the local SQLite database into production.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Python 3.12
- Node.js and npm
-
Clone the repository:
git clone https://github.com/toonshi/mikeblogs.git cd mikeblogs -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install Python dependencies:
pip install -r requirements.txt
-
Install Node.js dependencies:
npm install
-
Build frontend assets:
npm run build
-
Run database migrations:
python manage.py migrate
-
Run the development server:
python manage.py runserver
This project is configured for deployment on Render.
- The
build.shscript handles the build process. - The
Procfilespecifies the command to run the application. - The application is configured to use a PostgreSQL database in production.
Yes. The render.yaml blueprint is pre-configured to create and connect to the PostgreSQL database automatically:
| render.yaml setting | Value | Purpose |
|---|---|---|
databases[0].name |
fragile_thoughts |
Render service name for the database |
databases[0].databaseName |
fragile_thoughts |
Actual PostgreSQL database name |
databases[0].user |
fragile_thoughts_user |
PostgreSQL username |
envVars[DATABASE_URL].fromDatabase.name |
fragile_thoughts |
Links the web service to the database |
When deployed via Render blueprint, the DATABASE_URL environment variable is automatically injected from the database's internal connection string — no manual copy-paste of credentials is needed.
In lost/settings.py, when the RENDER environment variable is present, the app reads DATABASE_URL and configures Django to use PostgreSQL with SSL. On all other environments (local development) it falls back to SQLite.
Render's free PostgreSQL databases expire after 90 days. When this happens:
- The expired database is deleted from Render.
- Re-deploy the Render blueprint (
render.yaml) — Render will create a newfragile_thoughtsdatabase and automatically updateDATABASE_URLon the web service. - Run migrations via the Render shell:
python manage.py migrate
- Optionally re-load seed data (see Data Migration below).
Note: You do not need to hard-code any connection strings. The
fromDatabase: connectionStringinrender.yamlkeeps everything in sync automatically.
To develop against the Render production database from your local machine, copy .env.example to .env and set DATABASE_URL to the External Database URL shown in the Render dashboard for the fragile_thoughts database (it ends in .oregon-postgres.render.com). Make sure to append ?sslmode=require:
DATABASE_URL=postgresql://<user>:<password>@<hostname>.oregon-postgres.render.com/<dbname>?sslmode=require
To migrate data from a local SQLite database to a production PostgreSQL database, follow these steps:
-
Dump data from local SQLite database:
python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.permission -e admin > datadump.json -
Load data into production database: In the Render shell (or your production environment's shell), run the following command:
python manage.py loaddata datadump.json
- Django - The web framework used
- Tailwind CSS - For styling
- SQLite - Development database
- PostgreSQL - Production database
- Render - Deployment platform