Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📝 Blog

A simple and clean Django-based blog application that allows users to create, publish, edit, view, and delete blog posts.

The project uses Django's built-in authentication system to manage user accounts and restrict post management actions to authenticated users.


Python Django SQLite HTML5 CSS3


GitHub stars GitHub forks


📖 About the Project

Blog is a beginner-friendly Django web application built to demonstrate the fundamentals of developing a content management system with Django.

Users can register and authenticate themselves, create blog posts, view published content, and manage their own posts.

The project focuses on understanding Django's core concepts, including:

  • Django project and app structure
  • Models and database relationships
  • URL routing
  • Function/Class-based views
  • Django templates
  • Static files
  • Authentication and authorization
  • CRUD operations
  • Django Admin
  • Database migrations

✨ Features

👤 User Authentication

  • User registration
  • User login
  • User logout
  • Authentication-protected actions
  • Users can manage their own posts

📝 Blog Post Management

  • Create new blog posts
  • View all available posts
  • View individual post details
  • Edit existing posts
  • Delete posts
  • Restrict post management to the author

🎨 User Interface

  • Clean and simple UI
  • Django template-based frontend
  • Shared base template
  • Custom CSS styling
  • Responsive-friendly structure

⚙️ Administration

  • Django Admin interface
  • Manage users
  • Manage blog posts
  • Database management through Django Admin

🛠️ Tech Stack

Technology Purpose
Python Programming language
Django 6.0.4 Web framework
SQLite Development database
HTML5 Frontend markup
CSS3 Styling
Django Templates Server-side rendering
Django Authentication User authentication and authorization

🏗️ Project Architecture

The application follows Django's standard MVT (Model-View-Template) architecture.

User
 │
 ▼
URL Router
 │
 ▼
View
 │
 ├──────► Model ──────► SQLite Database
 │
 ▼
Template
 │
 ▼
HTML Response

Main Components

  • Models — Define the application's data structure.
  • Views — Handle HTTP requests and application logic.
  • URLs — Map URLs to the appropriate views.
  • Templates — Render HTML pages.
  • Static files — Provide CSS and frontend assets.
  • Authentication — Handles user registration and login.
  • Admin — Provides an interface for managing application data.

📂 Project Structure

blog/
├── accounts/
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations/
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   ├── urls.py
│   └── views.py
│
├── blog/
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── migrations/
│   │   ├── __init__.py
│   │   └── 0001_initial.py
│   ├── models.py
│   ├── static/
│   │   └── css/
│   │       └── base.css
│   ├── templates/
│   │   ├── base.html
│   │   ├── home.html
│   │   ├── post_delete.html
│   │   ├── post_detail.html
│   │   ├── post_edit.html
│   │   ├── post_new.html
│   │   └── registration/
│   │       ├── login.html
│   │       └── signup.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
│
├── django_project/
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
│
├── db.sqlite3
├── manage.py
└── README.md

🚀 Installation

1. Clone the repository

git clone https://github.com/Mahdiwav/blog.git
cd blog

2. Create a virtual environment

It is recommended to use a virtual environment to isolate the project's dependencies.

python -m venv venv

Activate it on Linux/macOS:

source venv/bin/activate

On Windows:

venv\Scripts\activate

3. Install Django

pip install django

4. Apply database migrations

python manage.py migrate

5. Create an admin user

To access Django Admin:

python manage.py createsuperuser

Follow the prompts to create your administrator account.

6. Start the development server

python manage.py runserver

The application will be available at:

http://127.0.0.1:8000/

💡 Usage

Once the development server is running, open:

http://127.0.0.1:8000/

Typical User Workflow

Register
   │
   ▼
Login
   │
   ▼
View Blog Posts
   │
   ▼
Create a Post
   │
   ▼
View Post
   │
   ├────► Edit Post
   │
   └────► Delete Post

Creating a Post

  1. Create an account or log in.
  2. Navigate to the homepage.
  3. Select New Blog Post.
  4. Enter the post title and content.
  5. Submit the form.
  6. The new post will appear on the blog.

Editing a Post

Open one of your own posts and select:

Edit Blog Post

Update the content and save the changes.

Deleting a Post

Open one of your own posts and select:

Delete Blog Post

Confirm the deletion to permanently remove the post.


🔐 Authentication & Authorization

The project uses Django's built-in authentication system.

Authentication is used to determine whether a user is logged in, while authorization controls which actions the user is allowed to perform.

For example:

Anonymous User
      │
      ├──► View Posts
      │
      └──► Read Post Details


Authenticated User
      │
      ├──► View Posts
      ├──► Create Post
      ├──► Edit Own Post
      └──► Delete Own Post

Users should only be able to modify or delete posts they are authorized to manage.


🗄️ Database

The project uses SQLite as its default database.

The database file is:

db.sqlite3

For development and learning purposes, SQLite provides a simple zero-configuration database solution.

For a production deployment, a more robust database such as PostgreSQL would generally be recommended.


🧪 Testing

The project contains Django test modules in the applications:

accounts/tests.py
blog/tests.py

Run the test suite with:

python manage.py test

You can use Django's testing framework to verify authentication, post creation, editing, deletion, permissions, and other application behavior.


🔧 Django Admin

Django provides a built-in administration interface for managing application data.

After creating a superuser, start the server and visit:

http://127.0.0.1:8000/admin/

The admin interface can be used to manage registered users and blog content.


🌐 API

This project does not currently provide a REST API.

All application interactions are handled through Django's server-rendered HTML templates.

If the project is extended in the future, Django REST Framework could be added to expose blog posts and user-related functionality through a RESTful API.


🤝 Contributing

Contributions are welcome!

If you would like to improve the project:

  1. Fork the repository.
  2. Create a feature branch:
git checkout -b feature/your-feature-name
  1. Make your changes.
  2. Commit your changes:
git add .
git commit -m "Add your feature"
  1. Push your branch:
git push origin feature/your-feature-name
  1. Open a Pull Request.

Please keep the existing project structure and coding conventions in mind when contributing.


📌 Future Improvements

Some potential improvements for future versions include:

  • Add Django REST Framework API
  • Add post categories
  • Add tags
  • Add comments
  • Add search functionality
  • Add pagination
  • Add image upload for posts
  • Add user profile pages
  • Improve responsive design
  • Add automated tests
  • Add CI with GitHub Actions
  • Deploy the application to a production environment
  • Replace SQLite with PostgreSQL for production

📄 License

This project is licensed under the MIT License.

See the LICENSE file for more information.


🔗 Important Links


⭐ Support

If you find this project useful:

  • ⭐ Star the repository
  • 🍴 Fork the repository
  • 🐛 Open an issue if you find a bug
  • 💡 Suggest improvements through GitHub Issues

📝 Blog

Built with ❤️ using Python & Django

Mahdi Faghani

GitHub Repository

About

Simple Django blog application with user authentication and CRUD functionality for blog posts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages