VOOZH about

URL: https://www.geeksforgeeks.org/python/blogging-platform-using-django/

⇱ Blogging Platform using Django - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Blogging Platform using Django

Last Updated : 23 Jul, 2025

Our task is to build a simple blogging platform using Django. We will learn how to create, display, edit, and delete blog posts with images using Django’s models, views, templates, and admin panel. Step-by-step, we’ll set up the project, connect it to a database, and run it locally.

Project Setup

Prerequisites:

Start by creating your Django project and app:

django-admin startproject blogsite
cd blogsite
python manage.py startapp gallery

Create the Product Model

The Product model represents a blog post with an image and timestamps.

gallery/models.py:

Register Model in Admin

gallery/admin.py:

Create a Form

gallery/forms.py:

Define Views

gallery/views.py:

URL Configuration

gallery/urls.py:

blogsite/urls.py:

Configure Media Settings

In blogsite/settings.py, add:

HTML Templates

Create a templates/myapp/ directory inside the gallery app and add the following:

edit.html: HTML file to edit the Blog.

delete.html: HTML file to delete the Blog.


index.html: HTML file to show all the list of the Blog.


index2.html: HTML file to show the full details of the Blog.

Install Required Packages

Make sure to install Pillow for image handling:

pip install Pillow

Database Setup and Superuser Creation

Apply Migrations

python manage.py makemigrations
python manage.py migrate

Create a Superuser

python manage.py createsuperuser

You will be prompted to enter a username, email, and password.

Once done, run:

python manage.py runserver

Visit: http://127.0.0.1:8000/admin/

Login using the superuser credentials and add blog entries with images via the admin interface.

πŸ‘ Screenshot-from-2023-10-01-14-26-49

Output:

πŸ‘ Screenshot-from-2023-10-02-17-09-25-(1)

πŸ‘ Screenshot-from-2023-10-02-17-10-22


πŸ‘ Screenshot-from-2023-10-02-17-11-44


πŸ‘ Screenshot-from-2023-10-02-17-10-44

Comment
Article Tags: