Skip to content

farzank69/blog-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Django Blog Application

A feature-rich blog application built with Django, featuring posts, comments, tags, and a read-later functionality.

Features

  • πŸ“ Blog posts with rich content
  • πŸ‘₯ Author management
  • 🏷️ Tag system for categorizing posts
  • πŸ’¬ Comment system for user engagement
  • πŸ”– Read-later functionality using sessions
  • πŸ“± Responsive design
  • πŸ”’ Admin panel for content management
  • πŸ–ΌοΈ Image upload support for posts

Tech Stack

  • Framework: Django 5.2.7
  • Database: SQLite (development) / PostgreSQL (production)
  • Python: 3.12.0
  • WSGI Server: Gunicorn
  • Static Files: WhiteNoise
  • Image Processing: Pillow

Project Structure

β”œβ”€β”€ blog/                   # Blog application
β”‚   β”œβ”€β”€ models.py          # Post, Author, Tag, Comment models
β”‚   β”œβ”€β”€ views.py           # Class-based views
β”‚   β”œβ”€β”€ forms.py           # Comment form
β”‚   β”œβ”€β”€ urls.py            # URL routing
β”‚   β”œβ”€β”€ templates/         # HTML templates
β”‚   └── static/            # CSS and images
β”œβ”€β”€ my_site/               # Project settings
β”‚   β”œβ”€β”€ settings.py        # Configuration
β”‚   β”œβ”€β”€ urls.py            # Root URL config
β”‚   └── wsgi.py            # WSGI configuration
β”œβ”€β”€ templates/             # Base templates
β”œβ”€β”€ static/                # Global static files
β”œβ”€β”€ uploads/               # Media uploads
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ build.sh              # Render build script
β”œβ”€β”€ render.yaml           # Render configuration
└── manage.py             # Django management script

Local Development Setup

Prerequisites

  • Python 3.12+
  • pip
  • virtualenv (recommended)

Installation

  1. Clone the repository

    git clone <your-repo-url>
    cd Section-11
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables

    cp .env.example .env
    # Edit .env with your settings
  5. Run migrations

    python manage.py migrate
  6. Create superuser

    python manage.py createsuperuser
  7. Collect static files

    python manage.py collectstatic
  8. Run development server

    python manage.py runserver
  9. Access the application

Production Deployment

This project is configured for deployment on Render.

Quick Deploy

  1. Push to GitHub
  2. Create Render account
  3. Use Blueprint deployment with render.yaml

For detailed instructions, see:

Database Models

Post

  • Title, slug, excerpt, content
  • Publication date (auto-generated)
  • Image upload
  • Author (Foreign Key)
  • Tags (Many-to-Many)

Author

  • First name, last name
  • Email address
  • Full name method

Tag

  • Caption (unique identifier)

Comment

  • User name and email
  • Comment text
  • Related post (Foreign Key)

URL Structure

  • / - Homepage (latest 3 posts)
  • /posts - All posts
  • /posts/<slug> - Individual post detail
  • /read-later - Saved posts
  • /admin - Admin panel

Configuration

Environment Variables

SECRET_KEY=<your-secret-key>
DEBUG=True|False
ALLOWED_HOSTS=localhost,127.0.0.1
DATABASE_URL=<postgresql-url>  # Production only

Static Files

  • Development: Served by Django
  • Production: Served by WhiteNoise

Media Files

  • Development: Local filesystem
  • Production: Recommend Cloudinary or S3

Security Features

Production deployment includes:

  • βœ… HTTPS redirect
  • βœ… Secure cookies
  • βœ… CSRF protection
  • βœ… XSS filtering
  • βœ… HSTS headers
  • βœ… Content type sniffing prevention

Development

Running Tests

python manage.py test

Creating Migrations

python manage.py makemigrations
python manage.py migrate

Adding Sample Data

Use Django admin panel or Django shell:

python manage.py shell

Common Tasks

Add a new blog post

  1. Login to admin panel
  2. Create Author (if needed)
  3. Create Tags (if needed)
  4. Create Post with title, content, slug, etc.

Manage comments

  • Comments appear on individual post pages
  • Moderate via admin panel

Troubleshooting

Static files not loading

python manage.py collectstatic --clear
python manage.py collectstatic

Database issues

python manage.py migrate --run-syncdb

Permission errors

chmod +x build.sh

Contributing

  1. Fork the repository
  2. Create feature branch
  3. Commit changes
  4. Push to branch
  5. Open pull request

Support

For general Django help, visit Django Documentation


Built with Django

About

A blog application built with Django, featuring posts, comments, tags and read-later functionality

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors