

{"id":117157,"date":"2023-11-06T18:00:49","date_gmt":"2023-11-06T12:30:49","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=117157"},"modified":"2023-11-06T18:06:54","modified_gmt":"2023-11-06T12:36:54","slug":"python-django-online-blog-cms","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/","title":{"rendered":"Python Django Online Blog CMS Project"},"content":{"rendered":"<p>A blog CMS is like a special software that helps people easily create and manage their blogs without needing to be super technical. It provides tools for organizing and editing content, managing user permissions, and customizing the design and functionality of the blog.<\/p>\n<h2>About Python Django Online Blog CMS<\/h2>\n<p>The objective of a Python Django online blog CMS is to simplify the process of creating and managing a blog by providing a user-friendly interface and tools for content creation, organization, and publication. It aims to empower individuals or organizations to easily share their ideas, insights, and information through a blog without the need for complex technical skills or coding knowledge.<\/p>\n<h3>Prerequisite For Python Django Online Blog CMS<\/h3>\n<ul>\n<li>It&#8217;s important to have a good grasp of the Python programming language and the Django web framework.<\/li>\n<li>A strong understanding of HTML, CSS, and JavaScript is required to develop the project&#8217;s user interface.<\/li>\n<li>Relational Database: You will need to have a good understanding of relational databases, such as SQLite, MySQL, or PostgreSQL, to create and manage the database for the Online voting system project.<\/li>\n<\/ul>\n<h3>Download Python Django Online Blog CMS Project<\/h3>\n<p>Please download the source code of Python Django Online Blog CMS Project: <a href=\"https:\/\/data-flair.s3.ap-south-1.amazonaws.com\/python-projects\/online-blog-cms.zip\"><strong>Python Django Online<\/strong>\u00a0<strong>Blog CMS Project Code.<\/strong><\/a><\/p>\n<h3>Project Setup<\/h3>\n<h4>Minimum system configuration:<\/h4>\n<ul>\n<li>The operating system requirements include Windows 7 or later, macOS 10.11 or later, or a modern operating system.<\/li>\n<li>A Linux distribution is like a ready-to-use operating system that comes with different software and settings. To use it, your computer should have an Intel Core i3 or similar processor, at least 4 GB of RAM (or more), and at least 5 GB of available storage space. You can use popular browsers such as Google Chrome, Mozilla Firefox, or Microsoft Edge to browse the web on Linux.<\/li>\n<\/ul>\n<h3>You can get Visual Studio Code by downloading it from the official website.<\/h3>\n<p>When you visit the download page, you&#8217;ll find different installers available for Windows, macOS, and Linux. You can choose the one that matches your operating system to download <a href=\"https:\/\/code.visualstudio.com\/download\">Visual Studio Code<\/a>. After downloading the installer, run it and proceed with the installation instructions to install VS Code on your computer.<br \/>\n<strong>Here&#8217;s a brief explanation of each step, along with the commands to execute:<\/strong><\/p>\n<p>1.\u00a0 To use Python, you need to install it on your computer. You can download the latest version of Python from the official website and follow the installation instructions provided for your operating system.<\/p>\n<p><strong>2. Install pip:<\/strong> Download the get-pip.py script and run python get-pip.py to install pip.<\/p>\n<p><strong>3. Create a virtual environment:<\/strong> Run python -m venv myenv to create a new virtual environment named &#8216;myenv&#8217;.<\/p>\n<p><strong>4. Activate the virtual environment:<\/strong> Run source myenv\/bin\/activate on Linux\/Mac or myenv\\Scripts\\activate on Windows to activate the virtual environment.<\/p>\n<p><strong>5. Install Django:<\/strong> Run pip install django to install the latest stable version of Django.<\/p>\n<p><strong>6. Verify installation:<\/strong> Run python -m django &#8211;version to verify that Django is installed correctly.<\/p>\n<p><strong>7. Create a new Django project:<\/strong> Run django-admin startproject project to create a new Django project named &#8216;project&#8217;.<\/p>\n<p><strong>8. Start the development server:<\/strong> Run python manage.py runserver to start the development server.<\/p>\n<p>That&#8217;s it! A working installation of Django should now be in place, and you should be ready to start building your web application.<\/p>\n<h3>Steps to Create \u201cOnline Blog CMS\u201d Project &#8211; Let&#8217;s Move ahead with this amazing project.<\/h3>\n<p>1. Open the terminal from the folder where we want to create the project. Right-click on mouse -&gt; open in terminal -&gt; write \u201ccode .\u201d (space is mandatory between code and \u201c.\u201d)<\/p>\n<p>2. Then go to the project folder -&gt; urls.py and inside urls.py of project, do this -&gt;add \u201cinclude\u201d in import as shown in the code below and add \u201cpath(&#8220;&#8221;,include(&#8220;app.urls&#8221;))\u201d<\/p>\n<p>3. Create urls.py in app of Online Blog CMS project(urls.py is mandatory in both the project and app).<\/p>\n<p>4. In setting.py, add the \u2018app name\u201d.<\/p>\n<p>5. Now, runserver to check if everything is working or not. To runserver, run command in the terminal as follows: \u201cpy manage.py runserver\u201d.<\/p>\n<p>6. Now create the models.py using ORM technique as follows.<\/p>\n<p><strong>To create the above field in a database, run the following commands as follows:<\/strong><\/p>\n<ul>\n<li>Py manage.py makemigrations<\/li>\n<li>Py manage.py migrate<\/li>\n<\/ul>\n<p><strong>The file structure will look like this for our project:<\/strong><\/p>\n<p>App(main) -&gt; Templates -&gt; app(folder inside app) -&gt; registration.html, login.html, votingpage.html.<\/p>\n<p><strong>Now, execute the project step by step with code as follows:<\/strong><\/p>\n<h3>Steps to Create Online Blog CMS Project &#8211; Let&#8217;s Move ahead with an amazing project:<\/h3>\n<p>1. Open the terminal from the folder where we want to create the project.<br \/>\nRight click on mouse -&gt; open in terminal -&gt; write \u201ccode .\u201d (space is mandatory between code and \u201c.\u201d)<\/p>\n<p>2. Open the terminal from the folder where we want to create the project.<br \/>\nRight click on mouse -&gt; open in terminal -&gt; write \u201ccode .\u201d (space is mandatory between code and \u201c.\u201d)<\/p>\n<p>3. Then go to the project folder -&gt; urls.py and inside urls.py of project, do this -&gt; add \u201cinclude\u201d in import as shown in the code below and add \u201cpath(&#8220;&#8221;, include(&#8220;app.urls&#8221;))\u201d<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.contrib import admin\r\nfrom django.urls import path, include\r\n\r\nurlpatterns = [\r\n    path('admin\/', admin.site.urls),\r\n    path(\"\", include(\"app.urls\"))\r\n]<\/pre>\n<p>4. Create urls.py in the app of the wishlist project(urls.py is mandatory in both project and app).<\/p>\n<p>5. In setting.py, add the \u2018app name\u201d. In my case, it is an app only, as below.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">INSTALLED_APPS = [\r\n    'django.contrib.admin',\r\n    'django.contrib.auth',\r\n    'django.contrib.contenttypes',\r\n    'django.contrib.sessions',\r\n    'django.contrib.messages',\r\n    'django.contrib.staticfiles',\r\n    'app'\r\n]<\/pre>\n<p>6. Now, runserver to check if everything is working or not. If you see the image below, then we are done with the installation part. To runserver, run the command in the terminal as follows: \u201cpy manage.py runserver\u201d.(if you see the rocket image, then it\u2019s working fine).<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/run-server.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120635 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/run-server.webp\" alt=\"run server\" width=\"896\" height=\"490\" \/><\/a><\/p>\n<p>7. Now create the models.py using ORM technique as follows.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.db import models\r\nfrom django.contrib.auth.models import User\r\n\r\n# Create your models here.\r\nclass Blog(models.Model):\r\n    title = models.CharField(max_length=100)\r\n    content = models.TextField()\r\n    author = models.ForeignKey(User, on_delete=models.CASCADE)\r\n    image = models.ImageField(upload_to='blog_images\/')\r\n    created_at = models.DateTimeField(auto_now_add=True)\r\n    updated_at = models.DateTimeField(auto_now=True)<\/pre>\n<p>8. Create a Registration system<br \/>\n<strong>templates\/app -&gt; registration.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;div class=\"content\"&gt;\r\n        &lt;div class=\"registration-form\"&gt;\r\n            &lt;form action=\"{% url 'registration' %}\" method=\"post\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" name=\"username\" placeholder=\"Username\" required&gt;\r\n                &lt;input type=\"text\" name=\"name\" placeholder=\"Name\" required&gt;\r\n                &lt;input type=\"email\" name=\"email\" placeholder=\"Email\" required&gt;\r\n                &lt;input type=\"password\" name=\"password\" placeholder=\"Password\" required&gt;\r\n                &lt;input type=\"password\" name=\"confirm_password\" placeholder=\"Confirm Password\" required&gt;\r\n                &lt;button type=\"submit\"&gt;Register&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;<\/pre>\n<p><strong>Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def register(request):\r\n    return render(request, \"app\/registration.html\")\r\n\r\ndef Registration(request):\r\n    if request.method == \"POST\":\r\n        username = request.POST['username']\r\n        name = request.POST['name']\r\n        email = request.POST['email']\r\n        password = request.POST['password']\r\n        cpassword = request.POST['confirm_password']\r\n\r\n        if password == cpassword:\r\n            new_data_created = User.objects.create(\r\n                username=username,\r\n                first_name = name,\r\n                email = email,\r\n            )\r\n            new_data_created.set_password(password)\r\n            new_data_created.save()\r\n            return redirect(\"login\")\r\n        else:\r\n            return render(request, \"app\/registration.html\")\r\n    return HttpResponse(\"error\")<\/pre>\n<p><strong>Urls.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">path(\"register\", register, name=\"register\"),<\/pre>\n<p>9. Create a login system<br \/>\n<strong>Templates.html -&gt; login.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;div class=\"header\"&gt;\r\n        &lt;h1&gt;Login&lt;\/h1&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;div class=\"content\"&gt;\r\n        &lt;div class=\"login-form\"&gt;\r\n            &lt;form action=\"{% url 'login' %}\" method=\"post\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" name=\"username\" placeholder=\"Username\" required&gt;\r\n                &lt;input type=\"password\" name=\"password\" placeholder=\"Password\" required&gt;\r\n                &lt;button type=\"submit\"&gt;Login&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;<\/pre>\n<p><strong>Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def Login_view(request):\r\n    if request.user.is_authenticated:\r\n        return redirect(\"show\")\r\n    else:\r\n        if request.method == \"POST\":\r\n            username = request.POST['username']\r\n            password = request.POST['password']\r\n\r\n            user = authenticate(request, username=username, password=password)\r\n\r\n            if user is not None:\r\n                login(request, user)\r\n                return redirect(\"show\")\r\n            else:\r\n                pass\r\n        return render(request, \"app\/login.html\")<\/pre>\n<p>10. For adding the data in the database.<br \/>\n<strong>templates\/app -&gt; add.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;div class=\"header\"&gt;\r\n        &lt;h1&gt;DataFlair Blog&lt;\/h1&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;div class=\"content\"&gt;\r\n        &lt;div class=\"post\"&gt;\r\n            &lt;h2&gt;Create a New Blog Post&lt;\/h2&gt;\r\n            &lt;form action=\"{% url 'created' %}\" method=\"post\" enctype=\"multipart\/form-data\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" name=\"title\" placeholder=\"Title\" required&gt;\r\n                &lt;input type=\"file\" name=\"image\" accept=\"image\/*\"&gt;\r\n                &lt;textarea name=\"content\" placeholder=\"Content\" required&gt;&lt;\/textarea&gt;\r\n                &lt;button type=\"submit\"&gt;Create&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;<\/pre>\n<p><strong> Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">@login_required(login_url=\"app\/login.html\")\r\ndef Created(request):\r\n    if request.method == \"POST\":\r\n        title = request.POST['title']\r\n        content = request.POST['content']\r\n        image = request.FILES.get('image')\r\n        author = request.POST.get('author')\r\n\r\n        new_data_created = Blog.objects.create(title=title, content=content, image=image, author=request.user)\r\n\r\n        return redirect(\"show\")\r\n    return HttpResponse(\"Error with post\")<\/pre>\n<p>12. Show data and update data<br \/>\n<strong>templates\/app -&gt; home.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;div id=\"header\"&gt;\r\n        &lt;h1&gt;DataFlair Blog&lt;\/h1&gt;\r\n        {% if user.is_authenticated %}\r\n        &lt;p&gt;Welcome, {{ user.username }}!!!&lt;\/p&gt;&lt;p&gt;{{ blog.author }}&lt;\/p&gt;\r\n        &lt;p&gt;&lt;a href=\"{% url 'addpage' %}\"&gt;&lt;button type=\"button\" class=\"add-blog\"&gt;Add Blog&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n        &lt;p&gt;&lt;a href=\"{% url 'signout' %}\"&gt;&lt;button type=\"button\" class=\"logout-blog\"&gt;Logout&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n        {% else %}\r\n        &lt;p&gt;&lt;a href=\"{% url 'login' %}\"&gt;&lt;button type=\"button\" class=\"add-blog\"&gt;Login&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n        &lt;p&gt;&lt;a href=\"{% url 'register' %}\"&gt;&lt;button type=\"button\" class=\"logout-blog\"&gt;Register&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n        {% endif %}\r\n    &lt;\/div&gt;\r\n    &lt;center&gt;\r\n        {% if show_data %}\r\n        {% for item in show_data %}\r\n        &lt;div id=\"content\"&gt;\r\n            &lt;div class=\"post\"&gt;\r\n                &lt;h2&gt;{{ item.title }}&lt;\/h2&gt;\r\n                &lt;p&gt;{{ item.content }}&lt;\/p&gt;\r\n                &lt;img src=\"{{ item.image.url }}\" alt=\"\" style=\"width: 400px; height: 400px;\"&gt;\r\n                &lt;p class=\"author\"&gt;Posted by {{ item.author }}&lt;\/p&gt;\r\n                &lt;p class=\"date\"&gt;{{ item.created_at }}&lt;\/p&gt;\r\n                {% if request.user == item.author %}\r\n                &lt;p&gt;&lt;a href=\"{% url 'delete' pk=item.pk %}\"&gt;&lt;button type=\"button\" class=\"action\"\r\n                            style=\"background-color: tomato;\"&gt;Delete&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n                &lt;p&gt;&lt;a href=\"{% url 'update' pk=item.pk %}\"&gt;&lt;button type=\"button\" class=\"action\"\r\n                            style=\"background-color: palegoldenrod;\"&gt;Update&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n                {% endif %}\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n\r\n        {% endfor %}\r\n        {% endif %}\r\n    &lt;\/center&gt;<\/pre>\n<p><strong> templates\/update.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;div class=\"header\"&gt;\r\n        &lt;h1&gt;DataFlair Blog&lt;\/h1&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;div class=\"content\"&gt;\r\n        &lt;div class=\"post\"&gt;\r\n            &lt;h2&gt;Edit&lt;\/h2&gt;\r\n            &lt;form action=\"{% url 'updated' pk=update_data.pk %}\" method=\"post\" enctype=\"multipart\/form-data\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" name=\"title\" placeholder=\"Title\" value=\"{{ update_data.title }}\" required&gt;\r\n                &lt;input type=\"file\" name=\"image\" accept=\"image\/*\"&gt;\r\n               \r\n                &lt;textarea name=\"content\" placeholder=\"Content\" required&gt;{{ update_data.content }}&lt;\/textarea&gt;\r\n                &lt;button type=\"submit\"&gt;update&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;<\/pre>\n<p><strong> Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def show(request):\r\n    show_data = Blog.objects.all()\r\n    return render(request, \"app\/home.html\", {\"show_data\": show_data})\r\n\r\n@login_required\r\ndef update(request, pk):\r\n    update_data = get_object_or_404(Blog, pk=pk)\r\n    return render(request, \"app\/update.html\", {\"update_data\": update_data})\r\n\r\n@login_required\r\ndef updated(request, pk):\r\n    updated_data = get_object_or_404(Blog, pk=pk)\r\n    if request.method == \"POST\":\r\n        updated_data.title = request.POST.get(\"title\")\r\n        updated_data.image = request.POST.get(\"image\")\r\n        updated_data.content = request.POST.get(\"content\")\r\n        updated_data.save()\r\n        return redirect(\"show\")\r\n    return HttpResponse(\"error\")<\/pre>\n<p>13. For delete<br \/>\n<strong>Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">@login_required\r\ndef delete(request, pk):\r\n    deleted_data = get_object_or_404(Blog, pk=pk)\r\n    deleted_data.delete()\r\n    return redirect(\"show\")<\/pre>\n<p>14. For signout<br \/>\n<strong>Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">@login_required\r\ndef signout(request):\r\n    logout(request)\r\n    return redirect(\"show\")<\/pre>\n<p><strong>For \u201curls.py\u201d for the above programs<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.conf import settings\r\nfrom django.conf.urls.static import static\r\nfrom django.urls import path, include\r\nfrom .views import *\r\n\r\nurlpatterns = [\r\n    path(\"register\", register, name=\"register\"),\r\n    path(\"addpage\", addpage, name=\"addpage\"),\r\n    path(\"registration\", Registration, name=\"registration\"),\r\n    path(\"login\", Login_view, name=\"login\"),\r\n    path(\"created\", Created, name=\"created\"),\r\n    path(\"\", show, name=\"show\"),\r\n    path(\"signout\", signout, name=\"signout\"),\r\n    path(\"update\/&lt;int:pk&gt;\", update, name=\"update\"),\r\n    path(\"updated\/&lt;int:pk&gt;\", updated, name=\"updated\"),\r\n    path(\"delete\/&lt;int:pk&gt;\", delete, name=\"delete\")\r\n\r\n]\r\nif settings.DEBUG:  \r\n        urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)<\/pre>\n<h3>Explanation for above:<\/h3>\n<p>The required imports are made, including Django shortcuts, authentication models, and decorators, as well as the Blog model defined in the same app.<\/p>\n<p>1. The Home view renders the home.html template.<\/p>\n<p>2. The register view renders the registration.html template.<\/p>\n<p>3. The addpage view, decorated with login_required, renders the add.html template, which allows authenticated users to add a new blog post.<\/p>\n<p>4. The Registration view handles the registration process. It retrieves form data (username, name, email, password, and confirm_password) via a POST request. If the passwords match, a new User object is created with the provided information, and the user is redirected to the login page. Otherwise, the registration template is rendered again.<\/p>\n<p>5. The Login_view view handles the login process. If the user is already authenticated, they are redirected to the show view. Otherwise, if the method is POST, the username and password are retrieved and checked against the authentication system. If the user is authenticated successfully, they are logged in and redirected to the show view. Otherwise, they stay on the login page.<\/p>\n<p>6. The Created view handles the creation of a new blog post. It retrieves the title, content, image (if provided), and author from a POST request. A new Blog object is created with this information, and the user is redirected to the show view.<\/p>\n<p>7. The show view retrieves all the Blog objects and renders the home.html template, passing the retrieved data as context.<\/p>\n<p>8. The updated view, decorated with login_required, retrieves a specific Blog object by its primary key (pk) and renders the update.html template, passing the retrieved data as context.<\/p>\n<p>9. The updated view, decorated with login_required, handles the updating of a specific blog post. It retrieves the updated data (title, content, and image) from a POST request and saves it to the corresponding Blog object. After a successful update, the user is redirected to the show view.<\/p>\n<p>10. The delete view, decorated with login_required, handles the deletion of a specific blog post. It retrieves the Blog object by its primary key and deletes it. Then, the user is redirected to the show view.<\/p>\n<p>11. The signout view, decorated with login_required, handles user logout. It logs out the current user and redirects to the show view.<\/p>\n<h3>The Entire code of the project is as follows:<\/h3>\n<p><strong>Templates -&gt; add.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;\r\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n    &lt;title&gt;Document&lt;\/title&gt;\r\n    &lt;style&gt;\r\n        body {\r\n            background-color: #f5f8fa;\r\n            font-family: Arial, sans-serif;\r\n        }\r\n\r\n        .header {\r\n            background-color: #1da1f2;\r\n            padding: 10px;\r\n            color: white;\r\n        }\r\n\r\n        .content {\r\n            max-width: 600px;\r\n            margin: 0 auto;\r\n            padding: 20px;\r\n        }\r\n\r\n        .post {\r\n            background-color: white;\r\n            border-radius: 10px;\r\n            padding: 20px;\r\n            margin-bottom: 20px;\r\n        }\r\n\r\n        .post h2 {\r\n            margin-top: 0;\r\n        }\r\n\r\n        form {\r\n            margin-top: 20px;\r\n        }\r\n\r\n        form input,\r\n        form textarea {\r\n            width: 100%;\r\n            padding: 10px;\r\n            margin-bottom: 10px;\r\n            border-radius: 5px;\r\n            border: 1px solid #ccc;\r\n        }\r\n\r\n        form button {\r\n            background-color: #1da1f2;\r\n            color: white;\r\n            padding: 10px 20px;\r\n            border: none;\r\n            border-radius: 5px;\r\n            cursor: pointer;\r\n        }\r\n\r\n        form button:hover {\r\n            background-color: #0c8ad6;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;div class=\"header\"&gt;\r\n        &lt;h1&gt;DataFlair Blog&lt;\/h1&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;div class=\"content\"&gt;\r\n        &lt;div class=\"post\"&gt;\r\n            &lt;h2&gt;Create a New Blog Post&lt;\/h2&gt;\r\n            &lt;form action=\"{% url 'created' %}\" method=\"post\" enctype=\"multipart\/form-data\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" name=\"title\" placeholder=\"Title\" required&gt;\r\n                &lt;input type=\"file\" name=\"image\" accept=\"image\/*\"&gt;\r\n                &lt;textarea name=\"content\" placeholder=\"Content\" required&gt;&lt;\/textarea&gt;\r\n                &lt;button type=\"submit\"&gt;Create&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/pre>\n<p><strong>templates\/app -&gt; home.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n\r\n&lt;head&gt;\r\n    &lt;title&gt;DataFlair Blog&lt;\/title&gt;\r\n    &lt;style&gt;\r\n        body {\r\n            font-family: Arial, sans-serif;\r\n            margin: 0;\r\n            padding: 0;\r\n        }\r\n\r\n        #header {\r\n            background-color: #00acee;\r\n            padding: 20px;\r\n            color: #fff;\r\n            text-align: center;\r\n        }\r\n\r\n        h1 {\r\n            margin: 0;\r\n        }\r\n\r\n        #content {\r\n            margin: 20px;\r\n        }\r\n\r\n        .post {\r\n            border: 1px solid #ddd;\r\n            border-radius: 5px;\r\n            padding: 20px;\r\n            margin-bottom: 20px;\r\n        }\r\n\r\n        .post h2 {\r\n            margin: 0;\r\n            font-size: 24px;\r\n        }\r\n\r\n        .post p {\r\n            margin: 10px 0;\r\n        }\r\n\r\n        .post .author {\r\n            color: #888;\r\n        }\r\n\r\n        .post .date {\r\n            color: #aaa;\r\n        }\r\n\r\n        .post .tags {\r\n            margin-top: 10px;\r\n        }\r\n\r\n        .tag {\r\n            display: inline-block;\r\n            padding: 5px;\r\n            background-color: #00acee;\r\n            color: #fff;\r\n            margin-right: 5px;\r\n            border-radius: 3px;\r\n            font-size: 14px;\r\n            text-decoration: none;\r\n        }\r\n\r\n        .tag:hover {\r\n            background-color: #0088cc;\r\n        }\r\n\r\n        .add-blog {\r\n            padding: 10px;\r\n            border-radius: 2px;\r\n            position: absolute;\r\n            left: 80%;\r\n            top: 2%;\r\n        }\r\n\r\n        .logout-blog {\r\n            padding: 10px;\r\n            border-radius: 2px;\r\n            position: absolute;\r\n            left: 86%;\r\n            top: 2%;\r\n        }\r\n\r\n        .action {\r\n            padding: 10px;\r\n            width: 10%;\r\n            color: white;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;div id=\"header\"&gt;\r\n        &lt;h1&gt;DataFlair Blog&lt;\/h1&gt;\r\n        {% if user.is_authenticated %}\r\n        &lt;p&gt;Welcome, {{ user.username }}!!!&lt;\/p&gt;&lt;p&gt;{{ blog.author }}&lt;\/p&gt;\r\n        &lt;p&gt;&lt;a href=\"{% url 'addpage' %}\"&gt;&lt;button type=\"button\" class=\"add-blog\"&gt;Add Blog&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n        &lt;p&gt;&lt;a href=\"{% url 'signout' %}\"&gt;&lt;button type=\"button\" class=\"logout-blog\"&gt;Logout&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n        {% else %}\r\n        &lt;p&gt;&lt;a href=\"{% url 'login' %}\"&gt;&lt;button type=\"button\" class=\"add-blog\"&gt;Login&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n        &lt;p&gt;&lt;a href=\"{% url 'register' %}\"&gt;&lt;button type=\"button\" class=\"logout-blog\"&gt;Register&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n        {% endif %}\r\n    &lt;\/div&gt;\r\n    &lt;center&gt;\r\n        {% if show_data %}\r\n        {% for item in show_data %}\r\n        &lt;div id=\"content\"&gt;\r\n            &lt;div class=\"post\"&gt;\r\n                &lt;h2&gt;{{ item.title }}&lt;\/h2&gt;\r\n                &lt;p&gt;{{ item.content }}&lt;\/p&gt;\r\n                &lt;img src=\"{{ item.image.url }}\" alt=\"\" style=\"width: 400px; height: 400px;\"&gt;\r\n                &lt;p class=\"author\"&gt;Posted by {{ item.author }}&lt;\/p&gt;\r\n                &lt;p class=\"date\"&gt;{{ item.created_at }}&lt;\/p&gt;\r\n                {% if request.user == item.author %}\r\n                &lt;p&gt;&lt;a href=\"{% url 'delete' pk=item.pk %}\"&gt;&lt;button type=\"button\" class=\"action\"\r\n                            style=\"background-color: tomato;\"&gt;Delete&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n                &lt;p&gt;&lt;a href=\"{% url 'update' pk=item.pk %}\"&gt;&lt;button type=\"button\" class=\"action\"\r\n                            style=\"background-color: palegoldenrod;\"&gt;Update&lt;\/button&gt;&lt;\/a&gt;&lt;\/p&gt;\r\n                {% endif %}\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n\r\n        {% endfor %}\r\n        {% endif %}\r\n    &lt;\/center&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>templates\/app -&gt; login.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;\r\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n    &lt;title&gt;Document&lt;\/title&gt;\r\n    &lt;style&gt;\r\n        body {\r\n            background-color: #f5f8fa;\r\n            font-family: Arial, sans-serif;\r\n        }\r\n\r\n        .header {\r\n            background-color: #1da1f2;\r\n            padding: 10px;\r\n            color: white;\r\n        }\r\n\r\n        .content {\r\n            max-width: 600px;\r\n            margin: 0 auto;\r\n            padding: 20px;\r\n        }\r\n\r\n        .login-form {\r\n            \r\n: white;\r\n            border-radius: 10px;\r\n            padding: 20px;\r\n            margin-bottom: 20px;\r\n        }\r\n\r\n        .login-form form {\r\n            margin-top: 20px;\r\n        }\r\n\r\n        .login-form input {\r\n            width: 100%;\r\n            padding: 10px;\r\n            margin-bottom: 10px;\r\n            border-radius: 5px;\r\n            border: 1px solid #ccc;\r\n        }\r\n\r\n        .login-form button {\r\n            background-color: #1da1f2;\r\n            color: white;\r\n            padding: 10px 20px;\r\n            border: none;\r\n            border-radius: 5px;\r\n            cursor: pointer;\r\n        }\r\n\r\n        .login-form button:hover {\r\n            background-color: #0c8ad6;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;div class=\"header\"&gt;\r\n        &lt;h1&gt;Login&lt;\/h1&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;div class=\"content\"&gt;\r\n        &lt;div class=\"login-form\"&gt;\r\n            &lt;form action=\"{% url 'login' %}\" method=\"post\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" name=\"username\" placeholder=\"Username\" required&gt;\r\n                &lt;input type=\"password\" name=\"password\" placeholder=\"Password\" required&gt;\r\n                &lt;button type=\"submit\"&gt;Login&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/pre>\n<p><strong>templates\/app -&gt; registration.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;\r\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n    &lt;title&gt;Document&lt;\/title&gt;\r\n    &lt;style&gt;\r\n        body {\r\n            background-color: #f5f8fa;\r\n            font-family: Arial, sans-serif;\r\n        }\r\n\r\n        .header {\r\n            background-color: #1da1f2;\r\n            padding: 10px;\r\n            color: white;\r\n        }\r\n\r\n        .content {\r\n            max-width: 600px;\r\n            margin: 0 auto;\r\n            padding: 20px;\r\n        }\r\n\r\n        .registration-form {\r\n            background-color: white;\r\n            border-radius: 10px;\r\n            padding: 20px;\r\n            margin-bottom: 20px;\r\n        }\r\n\r\n        .registration-form form {\r\n            margin-top: 20px;\r\n        }\r\n\r\n        .registration-form input {\r\n            width: 100%;\r\n            padding: 10px;\r\n            margin-bottom: 10px;\r\n            border-radius: 5px;\r\n            border: 1px solid #ccc;\r\n        }\r\n\r\n        .registration-form button {\r\n            background-color: #1da1f2;\r\n            color: white;\r\n            padding: 10px 20px;\r\n            border: none;\r\n            border-radius: 5px;\r\n            cursor: pointer;\r\n        }\r\n\r\n        .registration-form button:hover {\r\n            background-color: #0c8ad6;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;div class=\"header\"&gt;\r\n        &lt;h1&gt;Registration&lt;\/h1&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;div class=\"content\"&gt;\r\n        &lt;div class=\"registration-form\"&gt;\r\n            &lt;form action=\"{% url 'registration' %}\" method=\"post\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" name=\"username\" placeholder=\"Username\" required&gt;\r\n                &lt;input type=\"text\" name=\"name\" placeholder=\"Name\" required&gt;\r\n                &lt;input type=\"email\" name=\"email\" placeholder=\"Email\" required&gt;\r\n                &lt;input type=\"password\" name=\"password\" placeholder=\"Password\" required&gt;\r\n                &lt;input type=\"password\" name=\"confirm_password\" placeholder=\"Confirm Password\" required&gt;\r\n                &lt;button type=\"submit\"&gt;Register&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/pre>\n<p><strong>templates\/app -&gt; update.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n\r\n&lt;head&gt;\r\n    &lt;meta charset=\"UTF-8\"&gt;\r\n    &lt;meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"&gt;\r\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n    &lt;title&gt;Document&lt;\/title&gt;\r\n    &lt;style&gt;\r\n        body {\r\n            background-color: #f5f8fa;\r\n            font-family: Arial, sans-serif;\r\n        }\r\n\r\n        .header {\r\n            background-color: #1da1f2;\r\n            padding: 10px;\r\n            color: white;\r\n        }\r\n\r\n        .content {\r\n            max-width: 600px;\r\n            margin: 0 auto;\r\n            padding: 20px;\r\n        }\r\n\r\n        .post {\r\n            background-color: white;\r\n            border-radius: 10px;\r\n            padding: 20px;\r\n            margin-bottom: 20px;\r\n        }\r\n\r\n        .post h2 {\r\n            margin-top: 0;\r\n        }\r\n\r\n        form {\r\n            margin-top: 20px;\r\n        }\r\n\r\n        form input,\r\n        form textarea {\r\n            width: 100%;\r\n            padding: 10px;\r\n            margin-bottom: 10px;\r\n            border-radius: 5px;\r\n            border: 1px solid #ccc;\r\n        }\r\n\r\n        form button {\r\n            background-color: #1da1f2;\r\n            color: white;\r\n            padding: 10px 20px;\r\n            border: none;\r\n            border-radius: 5px;\r\n            cursor: pointer;\r\n        }\r\n\r\n        form button:hover {\r\n            background-color: #0c8ad6;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;div class=\"header\"&gt;\r\n        &lt;h1&gt;DataFlair Blog&lt;\/h1&gt;\r\n    &lt;\/div&gt;\r\n\r\n    &lt;div class=\"content\"&gt;\r\n        &lt;div class=\"post\"&gt;\r\n            &lt;h2&gt;Edit&lt;\/h2&gt;\r\n            &lt;form action=\"{% url 'updated' pk=update_data.pk %}\" method=\"post\" enctype=\"multipart\/form-data\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" name=\"title\" placeholder=\"Title\" value=\"{{ update_data.title }}\" required&gt;\r\n                &lt;input type=\"file\" name=\"image\" accept=\"image\/*\"&gt;\r\n               \r\n                &lt;textarea name=\"content\" placeholder=\"Content\" required&gt;{{ update_data.content }}&lt;\/textarea&gt;\r\n                &lt;button type=\"submit\"&gt;update&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.shortcuts import render, redirect, HttpResponse, get_object_or_404\r\nfrom django.contrib.auth.models import User\r\nfrom django.contrib.auth.decorators import login_required\r\nfrom django.contrib.auth import authenticate, login, logout\r\nfrom .models import Blog\r\n# Create your views here.\r\ndef Home(request):\r\n    return render(request, \"app\/home.html\")\r\n\r\ndef register(request):\r\n    return render(request, \"app\/registration.html\")\r\n\r\n@login_required(login_url=\"app\/login.html\")\r\ndef addpage(request):\r\n    return render(request, \"app\/add.html\")\r\n\r\ndef Registration(request):\r\n    if request.method == \"POST\":\r\n        username = request.POST['username']\r\n        name = request.POST['name']\r\n        email = request.POST['email']\r\n        password = request.POST['password']\r\n        cpassword = request.POST['confirm_password']\r\n\r\n        if password == cpassword:\r\n            new_data_created = User.objects.create(\r\n                username=username,\r\n                first_name = name,\r\n                email = email,\r\n            )\r\n            new_data_created.set_password(password)\r\n            new_data_created.save()\r\n            return redirect(\"login\")\r\n        else:\r\n            return render(request, \"app\/registration.html\")\r\n    return HttpResponse(\"error\")\r\n               \r\ndef Login_view(request):\r\n    if request.user.is_authenticated:\r\n        return redirect(\"show\")\r\n    else:\r\n        if request.method == \"POST\":\r\n            username = request.POST['username']\r\n            password = request.POST['password']\r\n\r\n            user = authenticate(request, username=username, password=password)\r\n\r\n            if user is not None:\r\n                login(request, user)\r\n                return redirect(\"show\")\r\n            else:\r\n                pass\r\n        return render(request, \"app\/login.html\")\r\n\r\n@login_required(login_url=\"app\/login.html\")\r\ndef Created(request):\r\n    if request.method == \"POST\":\r\n        title = request.POST['title']\r\n        content = request.POST['content']\r\n        image = request.FILES.get('image')\r\n        author = request.POST.get('author')\r\n\r\n        new_data_created = Blog.objects.create(title=title, content=content, image=image, author=request.user)\r\n\r\n        return redirect(\"show\")\r\n    return HttpResponse(\"Error with post\")\r\n\r\ndef show(request):\r\n    show_data = Blog.objects.all()\r\n    return render(request, \"app\/home.html\", {\"show_data\": show_data})\r\n\r\n@login_required\r\ndef update(request, pk):\r\n    update_data = get_object_or_404(Blog, pk=pk)\r\n    return render(request, \"app\/update.html\", {\"update_data\": update_data})\r\n\r\n@login_required\r\ndef updated(request, pk):\r\n    updated_data = get_object_or_404(Blog, pk=pk)\r\n    if request.method == \"POST\":\r\n        updated_data.title = request.POST.get(\"title\")\r\n        updated_data.image = request.POST.get(\"image\")\r\n        updated_data.content = request.POST.get(\"content\")\r\n        updated_data.save()\r\n        return redirect(\"show\")\r\n    return HttpResponse(\"error\")\r\n\r\n@login_required\r\ndef delete(request, pk):\r\n    deleted_data = get_object_or_404(Blog, pk=pk)\r\n    deleted_data.delete()\r\n    return redirect(\"show\")\r\n\r\n@login_required\r\ndef signout(request):\r\n    logout(request)\r\n    return redirect(\"show\")<\/pre>\n<p><strong>Urls.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.conf import settings\r\nfrom django.conf.urls.static import static\r\nfrom django.urls import path, include\r\nfrom .views import *\r\n\r\nurlpatterns = [\r\n    path(\"register\", register, name=\"register\"),\r\n    path(\"addpage\", addpage, name=\"addpage\"),\r\n    path(\"registration\", Registration, name=\"registration\"),\r\n    path(\"login\", Login_view, name=\"login\"),\r\n    path(\"created\", Created, name=\"created\"),\r\n    path(\"\", show, name=\"show\"),\r\n    path(\"signout\", signout, name=\"signout\"),\r\n    path(\"update\/&lt;int:pk&gt;\", update, name=\"update\"),\r\n    path(\"updated\/&lt;int:pk&gt;\", updated, name=\"updated\"),\r\n    path(\"delete\/&lt;int:pk&gt;\", delete, name=\"delete\")\r\n\r\n]\r\nif settings.DEBUG:  \r\n        urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)<\/pre>\n<p><strong>Models.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.db import models\r\nfrom django.contrib.auth.models import User\r\n\r\n# Create your models here.\r\nclass Blog(models.Model):\r\n    title = models.CharField(max_length=100)\r\n    content = models.TextField()\r\n    author = models.ForeignKey(User, on_delete=models.CASCADE)\r\n    image = models.ImageField(upload_to='blog_images\/')\r\n    created_at = models.DateTimeField(auto_now_add=True)\r\n    updated_at = models.DateTimeField(auto_now=True)<\/pre>\n<h3>Python Django Online Blog CMS Output<\/h3>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/new-blog-post.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120636 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/new-blog-post.webp\" alt=\"new blog post\" width=\"1920\" height=\"883\" \/><\/a><\/p>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/django-online-blog-output-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120639 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/django-online-blog-output-1.webp\" alt=\"django online blog output\" width=\"1920\" height=\"882\" \/><\/a><\/h3>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/python-djnago-online-blog-cms-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120640 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/python-djnago-online-blog-cms-output.webp\" alt=\"python django online blog cms output\" width=\"1920\" height=\"884\" \/><\/a><\/h3>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-blog-login.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120641 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-blog-login.webp\" alt=\"online blog login\" width=\"1920\" height=\"891\" \/><\/a><\/h3>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-blog-registration.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120642 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-blog-registration.webp\" alt=\"online blog registration\" width=\"1918\" height=\"889\" \/><\/a><\/h3>\n<h3>Summary:<\/h3>\n<p>The provided Django code implements a basic blog application with user registration, login, and CRUD (Create, Read, Update, Delete) functionality for blog posts. It allows users to register, log in, add new posts, view all posts, update existing posts, and delete posts. The application utilizes Django&#8217;s authentication system and models for user management and blog post storage.<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:181,&quot;href&quot;:&quot;https:\\\/\\\/data-flair.s3.ap-south-1.amazonaws.com\\\/python-projects\\\/online-blog-cms.zip&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251206234550\\\/https:\\\/\\\/data-flair.s3.ap-south-1.amazonaws.com\\\/python-projects\\\/online-blog-cms.zip&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-23 08:17:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 06:07:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-23 03:30:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-05 11:03:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-30 15:52:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-16 15:26:01&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-06-21 20:20:22&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-06-30 05:50:57&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-30 05:50:57&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:106,&quot;href&quot;:&quot;https:\\\/\\\/code.visualstudio.com\\\/download&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251204121135\\\/https:\\\/\\\/code.visualstudio.com\\\/download&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-05 21:21:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-09 06:36:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-13 13:39:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-16 16:39:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-20 05:48:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-23 15:52:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-26 16:42:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-30 06:04:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-03 08:38:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-06 11:44:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-09 15:03:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-12 17:34:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-16 07:23:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-19 08:10:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-22 12:08:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-25 13:13:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-28 16:33:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-02 06:09:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-05 11:09:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 05:12:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-13 09:16:38&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-16 09:57:52&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 19:12:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 07:09:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 11:07:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 02:56:23&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 10:14:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-10 09:42:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-13 21:54:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 09:04:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 09:38:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-25 18:47:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-29 09:14:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-01 13:26:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-05 13:53:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-08 14:38:46&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-12 03:23:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 10:52:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 16:28:11&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-22 05:16:24&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-25 15:25:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-28 18:00:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-02 00:06:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-05 06:50:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-11 05:39:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-14 08:20:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-17 14:13:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-21 06:49:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-25 07:48:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-28 08:01:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-31 15:28:21&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-03 17:34:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-06 23:32:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-10 14:18:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-13 15:09:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-17 05:27:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-21 17:20:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-26 11:58:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-30 04:57:07&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-30 04:57:07&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A blog CMS is like a special software that helps people easily create and manage their blogs without needing to be super technical. It provides tools for organizing and editing content, managing user permissions,&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":120638,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19149],"tags":[28305,19201,28306,28307,28304,21613,27783,28308],"class_list":["post-117157","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-django","tag-django-online-blog-cms-project","tag-django-project","tag-online-blog-cms","tag-online-blog-cms-project","tag-python-django-online-blog-cms-project","tag-python-django-project","tag-python-django-project-for-practice","tag-python-django-project-ideas"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Django Online Blog CMS Project - DataFlair<\/title>\n<meta name=\"description\" content=\"The online blog CMS is of creating and managing a blog by providing a user-friendly interface and tools for content creation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Django Online Blog CMS Project - DataFlair\" \/>\n<meta property=\"og:description\" content=\"The online blog CMS is of creating and managing a blog by providing a user-friendly interface and tools for content creation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-06T12:30:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-06T12:36:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/python-django-online-blog-cms-1.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Django Online Blog CMS Project - DataFlair","description":"The online blog CMS is of creating and managing a blog by providing a user-friendly interface and tools for content creation.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/","og_locale":"en_US","og_type":"article","og_title":"Python Django Online Blog CMS Project - DataFlair","og_description":"The online blog CMS is of creating and managing a blog by providing a user-friendly interface and tools for content creation.","og_url":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-11-06T12:30:49+00:00","article_modified_time":"2023-11-06T12:36:54+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/python-django-online-blog-cms-1.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"Python Django Online Blog CMS Project","datePublished":"2023-11-06T12:30:49+00:00","dateModified":"2023-11-06T12:36:54+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/"},"wordCount":1523,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/python-django-online-blog-cms-1.webp","keywords":["django online blog cms project","Django Project","online blog cms","online blog cms project","python django online blog cms project","python django project","python django project for practice","python django project ideas"],"articleSection":["Django Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/","url":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/","name":"Python Django Online Blog CMS Project - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/python-django-online-blog-cms-1.webp","datePublished":"2023-11-06T12:30:49+00:00","dateModified":"2023-11-06T12:36:54+00:00","description":"The online blog CMS is of creating and managing a blog by providing a user-friendly interface and tools for content creation.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/python-django-online-blog-cms-1.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/python-django-online-blog-cms-1.webp","width":1200,"height":628,"caption":"python django online blog cms"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-django-online-blog-cms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Django Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/django\/"},{"@type":"ListItem","position":3,"name":"Python Django Online Blog CMS Project"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/117157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=117157"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/117157\/revisions"}],"predecessor-version":[{"id":124405,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/117157\/revisions\/124405"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/120638"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=117157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=117157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=117157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}