0% found this document useful (0 votes)
43 views11 pages

Creating A Blog Platform Using Django - by SarahDev - Jul, 2023 - Medium

The document is a tutorial about creating a blog platform using the Django web framework. It discusses setting up a Django project called "blog_platform", creating a "blog" app, defining models for blog posts, categories, tags, and comments, and includes steps for the project setup, creating the blog app, and defining the models. The full tutorial is locked for Medium members only.

Uploaded by

missawiiyassin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views11 pages

Creating A Blog Platform Using Django - by SarahDev - Jul, 2023 - Medium

The document is a tutorial about creating a blog platform using the Django web framework. It discusses setting up a Django project called "blog_platform", creating a "blog" app, defining models for blog posts, categories, tags, and comments, and includes steps for the project setup, creating the blog app, and defining the models. The full tutorial is locked for Medium members only.

Uploaded by

missawiiyassin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

Member-only story

Creating a Blog Platform using Django


SarahDev · Follow
4 min read · Jul 26

Listen Share

Creating a Blog Platform using Django is an excellent project to improve your web
development skills. In this tutorial, I’ll guide you through the steps to build a fully
functional blog application where users can register, create, publish blog posts, and
interact with comments. Additionally, we’ll include an admin panel for managing
blog posts, user accounts, and comments.

Prerequisites:
Before you start, make sure you have the following installed on your system:

Python (https://www.python.org/downloads/)

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 1/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

Django (You can install it using pip: pip install Django )

Step 1: Project Setup


1. Create a new Django project called “blog_platform”:

django-admin startproject blog_platform

2. Navigate to the project directory:

cd blog_platform

Step 2: Create the Blog App


1. Create a new Django app called “blog”:
Open in app Sign up Sign In

python manage.py startapp blog

2. Add the “blog” app to the project’s settings.py:

# blog_platform/settings.py

INSTALLED_APPS = [
# Other apps...
'blog',
]

Step 3: Define the Models


1. Open blog/models.py and define the models for blog posts, categories, and
comments:

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 2/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

# blog/models.py

from django.db import models


from django.contrib.auth.models import User

class Category(models.Model):
name = models.CharField(max_length=100)

def __str__(self):
return self.name

class Post(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
title = models.CharField(max_length=200)
content = models.TextField()
category = models.ForeignKey(Category, on_delete=models.CASCADE)
tags = models.ManyToManyField('Tag', blank=True)
pub_date = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.title

class Tag(models.Model):
name = models.CharField(max_length=50)

def __str__(self):
return self.name

class Comment(models.Model):
post = models.ForeignKey(Post, on_delete=models.CASCADE)
user = models.ForeignKey(User…

Read the full story with a free account.


The author made this story available to Medium members only.
Sign up to read this one for free.

Continue in app

Or, continue in mobile web

Sign up with Google

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 3/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

Sign up with Facebook

Sign up with email

Already have an account? Sign in

Follow

Written by SarahDev
149 Followers

Buy me a Coffee: https://bmc.link/sarahdev Access to my Github: bit.ly/3KDPw6G

More from SarahDev

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 4/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

SarahDev

Building an E-commerce Website using Django


Building an E-commerce Website using Django will be a challenging but rewarding project. In
this tutorial, I’ll guide you through the steps…

· 4 min read · Jul 26

26

SarahDev

Building an Event Management System using Django


Building an Event Management System using Django will be an exciting project that allows
users to create, manage, and join events. In this…

· 4 min read · Jul 26

41 2

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 5/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

SarahDev

Building a Social Media Network in Laravel: A Step-by-Step Tutorial


In this tutorial, we’ll guide you through the process of building a social media platform using
Laravel. Users will be able to post…

· 4 min read · Jul 23

22

SarahDev

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 6/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

Building a Customer Relationship Management (CRM) Software with


Laravel
In this tutorial, we will guide you through the process of building a basic Customer Relationship
Management (CRM) software using the…

· 6 min read · Jul 25

See all from SarahDev

Recommended from Medium

Pwaveino Clarkson

How to Build Your Blog in Django: Rapid Development in Under 30


Minutes!
How to build a seamless and simple blog using the Django Web Development Framework.

7 min read · Aug 6

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 7/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

DevSumitG

Django Auth User Signup and Login


Check out my previous blog about Django Best Practices: Tips for Writing Better Code.

8 min read · Jul 5

19

Lists

Coding & Development


11 stories · 155 saves

Predictive Modeling w/ Python


20 stories · 361 saves

Practical Guides to Machine Learning


10 stories · 400 saves

New_Reading_List
174 stories · 96 saves

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 8/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

Hivan du

39. Django: Building a Monitoring Platform


Hi, I’m Hivan.

9 min read · Jun 27

46

elijah samson in AWS Tip

Django: Function-Based Views vs Class-Based Views

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 9/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

Django is a powerful web framework for building web applications in Python. When it comes to
handling views, Django provides two main…

8 min read · Jul 18

30

Suhas Tumati

Django fields
In this reading, you will learn about different field types in a model class.

6 min read · Aug 3

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 10/11
09/09/2023 19:00 Creating a Blog Platform using Django | by SarahDev | Jul, 2023 | Medium

Shreyash Sikarwar in Python in Plain English

Django Models Some Hidden Features


Hey fellow developers,

3 min read · Aug 28

11

See more recommendations

https://medium.com/@sarahisdevs/creating-a-blog-platform-using-django-15ffe36527cc 11/11

You might also like