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.
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
- User registration
- User login
- User logout
- Authentication-protected actions
- Users can manage their own posts
- Create new blog posts
- View all available posts
- View individual post details
- Edit existing posts
- Delete posts
- Restrict post management to the author
- Clean and simple UI
- Django template-based frontend
- Shared base template
- Custom CSS styling
- Responsive-friendly structure
- Django Admin interface
- Manage users
- Manage blog posts
- Database management through Django Admin
| 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 |
The application follows Django's standard MVT (Model-View-Template) architecture.
User
│
▼
URL Router
│
▼
View
│
├──────► Model ──────► SQLite Database
│
▼
Template
│
▼
HTML Response
- 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.
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
git clone https://github.com/Mahdiwav/blog.git
cd blogIt is recommended to use a virtual environment to isolate the project's dependencies.
python -m venv venvActivate it on Linux/macOS:
source venv/bin/activateOn Windows:
venv\Scripts\activatepip install djangopython manage.py migrateTo access Django Admin:
python manage.py createsuperuserFollow the prompts to create your administrator account.
python manage.py runserverThe application will be available at:
http://127.0.0.1:8000/
Once the development server is running, open:
http://127.0.0.1:8000/
Register
│
▼
Login
│
▼
View Blog Posts
│
▼
Create a Post
│
▼
View Post
│
├────► Edit Post
│
└────► Delete Post
- Create an account or log in.
- Navigate to the homepage.
- Select New Blog Post.
- Enter the post title and content.
- Submit the form.
- The new post will appear on the blog.
Open one of your own posts and select:
Edit Blog Post
Update the content and save the changes.
Open one of your own posts and select:
Delete Blog Post
Confirm the deletion to permanently remove the post.
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.
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.
The project contains Django test modules in the applications:
accounts/tests.py
blog/tests.py
Run the test suite with:
python manage.py testYou can use Django's testing framework to verify authentication, post creation, editing, deletion, permissions, and other application behavior.
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.
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.
Contributions are welcome!
If you would like to improve the project:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/your-feature-name- Make your changes.
- Commit your changes:
git add .
git commit -m "Add your feature"- Push your branch:
git push origin feature/your-feature-name- Open a Pull Request.
Please keep the existing project structure and coding conventions in mind when contributing.
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
This project is licensed under the MIT License.
See the LICENSE file for more information.
- GitHub Repository: https://github.com/Mahdiwav/blog
- Issues: https://github.com/Mahdiwav/blog/issues
- Pull Requests: https://github.com/Mahdiwav/blog/pulls
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