Blog Application In Django With Source Code
The Blog Application In Django is developed using Python Django, HTML,CSS and JavaScript, This Django Blog Application is a complete blogging site for the users where users can add, edit and delete their blogs and share to everyone on the world.
A Blog In Django contains all the features of a Blog site like login/register into the system, add blog post with title, description and image and edit or delete the blog post. In this tutorial will teach you on How To Create A Blog In Django
Creating A Blog In Django has interactive UI design using which users can see what others are posting. It also has an admin panel through which all the blog posts and users can be managed.
Watch the video here to see the full Blog Application In Django With Source Code
This Blog Application In Django also includes a downloadable Project With Source Code for free, just find the downloadable source code below and click to start downloading.
To start creating a Blog Application In Django, makes sure that you have PyCharm Professional IDE Installed in your computer.
Reminders
To perform this python django project make sure that you have knowledge in the following:
- CSS
- HTML
- Javascript
- Database Management
Features Of This Blog Application In Django
- Manage Blog – In this feature includes the CRUD operation in a blog or content you create like adding, editing and deleting content of the blog
- Login System – In this feature the admin can login to the system and manage all the feature of the system.
In This Blog Application In Django Consist Of The Following Method:
- Blog – In this method which is the main method of the system.
- Media – In this method which you can found all the media that you are upload in the system.
- Template – In this method which is the design of the system that consist of HTML,CSS and JavaScript.
Steps on how to create a Blog Application In Django With Source Code
Blog Application In Django With Source Code
- Step 1: Open file.
First , open “pycharm professional” after that click “file” and click “new project“.
- Step 2: Choose Django.
Second, after click “new project“, choose “Django” and click.
- Step 3: Select file location.
Third, select a file location wherever you want.
- Step 4: Create application name.
Fourth, name your application.
- Step 5: Click create.
Fifth, finish creating project by clicking “create” button.
- Step 6: Start of coding.
you are free to copy the following codes below in the given modules and method required.
The List Of Module Given Below Are Under The “Blog” Method
- The Code Given Below Is For The “views.py” Module – you can add the following code below into your “views.py” under the “Blog” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
from django.shortcuts import render, get_object_or_404, redirect from django.utils import timezone from .models import Post from .forms import PostForm def post_list(request): posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') return render(request, 'blog/post_list.html', {'posts': posts}) def post_detail(request, pk): post = get_object_or_404(Post, pk=pk) return render(request, 'blog/post_detail.html', {'post': post}) def post_new(request): if request.method == "POST": form = PostForm(request.POST, request.FILES) if form.is_valid(): post = form.save(commit=False) post.author = request.user post.published_date = timezone.now() post.save() return redirect('post_detail', pk=post.pk) else: form = PostForm() return render(request, 'blog/post_edit.html', {'form': form}) def post_edit(request, pk): post = get_object_or_404(Post, pk=pk) if request.method == "POST": form = PostForm(request.POST, request.FILES, instance=post) if form.is_valid(): post = form.save(commit=False) post.author = request.user post.published_date = timezone.now() post.save() return redirect('post_detail', pk=post.pk) else: form = PostForm(instance=post) return render(request, 'blog/post_edit.html', {'form': form}) |
In this module which is the index module of the blog method.
- The Code Given Below Is For The “urls.py” Module – you can add the following code below into your “urls.py” under the “Blog” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from django.conf.urls import url from django.contrib.auth import views as auth_views from . import views urlpatterns = [ url(r'^$', views.post_list, name='post_list'), url(r'^login/$', auth_views.login, {'template_name': 'blog/login.html'}, name='login'), url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'), url(r'^post/(?P<pk>\d+)/edit/$', views.post_edit, name='post_edit'), url(r'^post/new/$', views.post_new, name='post_new'), ] |
In this module which is the URL configuration module under blog method.
- The Code Given Below Is For The “models.py” Module – you can add the following code below into your “models.py” under the “Blog” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from django.db import models from django.utils import timezone class Post(models.Model): author = models.ForeignKey('auth.User', on_delete=models.CASCADE) title = models.CharField(max_length=200) text = models.TextField() image = models.ImageField("Image", blank=True, null=True, upload_to="images/") created_date = models.DateTimeField( default=timezone.now) published_date = models.DateTimeField( blank=True, null=True) def publish(self): self.published_date = timezone.now() self.save() def __str__(self): return self.title |
In this module which you can found classes to be call under blog method.
I have here the list of Best Python Project with Source code free to download for free, I hope this can help you a lot.
Run Quick Virus Scan for secure Download
Run Quick Scan for secure DownloadDownloadable Source Code Below.
Anyway, if you want to level up your programming knowledge, especially python, try this new article I’ve made for you Best Python Projects with source code for Beginners. But If you’re going to focus on web development using Django, you can download here from our list of Best Django Projects with source code based on real-world projects.
How To Run The Blog Application In Django?
Step 1: Extract/unzip the file
Step 2: Go inside the project folder, open cmd and type the following commands to install Django Framework and run the webserver:
1.) python manage.py runserver
Step 3: Finally, open the browser and go to localhost:8000

Summary
The system is built fully in Django Framework in back-end and HTML, CSS in front-end. It has full-featured user interface with all the functionalities
This Article is the way to enhance and develop our skills and logic ideas which is important in practicing the python programming language which is most well known and most usable programming language in many company.
Related article below
- How To Make A Point Of Sale System In Python
- Best Python Projects for Beginners
- Python MySQL Connection: Simple Python Step by Step Guide
- Python PIP Command Set-up / Fix: Step by Step Guide
- Random Password Generator in Python Projects With Source Code 2020
- Python Range Function|Range in Python Explained with Examples 2020
Inquiries
If you have any questions or suggestions about Blog Application In Django, please feel free to leave a comment below.