

{"id":118536,"date":"2023-10-30T19:00:23","date_gmt":"2023-10-30T13:30:23","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=118536"},"modified":"2026-06-01T12:01:24","modified_gmt":"2026-06-01T06:31:24","slug":"python-django-online-voting-system","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/","title":{"rendered":"Python Django Project \u2013 Online Voting System"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:2509,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1zYkOwwHzgZHhtfKvaW7Zq0DBj4kZ8lS3\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601063235\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1zYkOwwHzgZHhtfKvaW7Zq0DBj4kZ8lS3\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-02 03:40:23&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-05 03:58:00&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-05 03:58:00&quot;,&quot;http_code&quot;:200},&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;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-03 17:34:37&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>An online voting system, also known as e-voting, is a digital platform that allows eligible voters to cast their votes remotely using the internet. It is a modern alternative to traditional paper-based voting methods. With an online voting system, voters can access the voting process through a secure website or a dedicated voting application.<\/p>\n<h2>About Python Django Online Voting System<\/h2>\n<p>The objective of a Python Django online voting system is to provide a convenient and efficient method for eligible voters to cast their votes remotely using the internet.<\/p>\n<h3>Prerequisite For Online Voting System Using Python Django<\/h3>\n<ul>\n<li>A solid understanding of the Python programming language and the Django web framework is necessary.<\/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 Voting System Project<\/h3>\n<p>Please download the source code of the Python Django Online Voting System:<strong><a href=\"https:\/\/drive.google.com\/file\/d\/1zYkOwwHzgZHhtfKvaW7Zq0DBj4kZ8lS3\/view?usp=drive_link\"> Python Django Online Voting System Project Code.<\/a><\/strong><\/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>Linux distribution.<\/li>\n<li>Processor: Intel Core i3 or equivalent.<\/li>\n<li>RAM: 4 GB or more<\/li>\n<li>Disk Space: 5 GB or more.<\/li>\n<li>Browsers such as Google Chrome, Mozilla Firefox, or Microsoft Edge can be used.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/code.visualstudio.com\/download\">Visual Studio Code<\/a> can be downloaded from the official website.<\/p>\n<p>On the download page, you can select the suitable installer for your operating system (Windows, macOS, or Linux). After downloading the installer, run it and proceed with the installation instructions to install VS Code on your computer.<\/p>\n<p><strong>Here&#8217;s a brief explanation of each step, along with the commands to execute:<\/strong><\/p>\n<p><strong>1. Python should be installed:<\/strong> Download and install the latest version of Python from the official website, following the installation instructions for your operating system.<br \/>\n<strong>2. Install pip:<\/strong> Download the get-pip.py script and run python get-pip.py to install pip.<br \/>\n<strong>3. Create a virtual environment:<\/strong> Run python -m venv myenv to create a new virtual environment named &#8216;myenv&#8217;.<br \/>\n<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.<br \/>\n<strong>5. Install Django:<\/strong> Run pip install django to install the latest stable version of Django.<br \/>\n<strong>6. Verify installation:<\/strong> Run python -m django &#8211;version to verify that Django is installed correctly.<br \/>\n<strong>7. Create a new Django project:<\/strong> Run django-admin startproject project to create a new Django project named &#8216;project&#8217;.<br \/>\n<strong>8. Start the development server:<\/strong> Run python manage.py runserver to start the development server.<br \/>\nThat&#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 a \u201c Python Django Voting System\u201d Project &#8211; Let&#8217;s Move ahead with this amazing project.<\/h3>\n<p>1. Open the terminal fromfolder 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 the app of Pin your Notes 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. If you see the below image, then we are done with the installation part. To runserver, run command in terminal as follows \u201cpy manage.py runserver\u201d.<\/p>\n<p>6. Now, create the models.py using the ORM technique as follows.<\/p>\n<p><strong>To create the above field in a database, run the following commands as follows:<\/strong><br \/>\n\u25cf Py manage.py makemigrations<br \/>\n\u25cf Py manage.py migrate<\/p>\n<p><strong>The file structure will look like this for our project:<\/strong><br \/>\nApp(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 Django Online Voting System 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. 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>3. Create urls.py in an app of wishlistproject(urls.py is mandatory in both the project and app).<\/p>\n<p>4. In setting.py, add the \u2018app name\u201d. In my case, it is the 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>5. Now runserver to check, if everything is working or not. If you see below image, then we are done with the installation part. To runserver, run command in terminal as follows \u201cpy manage.py runserver\u201d.(if you see the rocket image, then it\u2019s working fine).<\/p>\n<p>6. 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\nfrom django.core.validators import MinValueValidator\r\n# Create your models here.\r\nclass Questions(models.Model):\r\n    user = models.OneToOneField(User, on_delete=models.CASCADE)\r\n    ques = models.CharField(max_length=150)\r\n    option1 = models.CharField(max_length=150)\r\n    option2 = models.CharField(max_length=150)\r\n    option3 = models.CharField(max_length=150)\r\n    option4 = models.CharField(max_length=150)\r\n    vote1 = models.IntegerField(default=0)\r\n    vote2 = models.IntegerField(default=0)\r\n    vote3 = models.IntegerField(default=0)\r\n    vote4 = models.IntegerField(default=0)\r\n    vote = models.IntegerField(default=False, verbose_name=\"How many object created for this questions?\")\r\n    is_closed = models.BooleanField(default=False)\r\n\r\n    @property\r\n    def total_votes(self):\r\n        return self.vote1 + self.vote2 + self.vote3 + self.vote4\r\n    \r\n    @property\r\n    def get_winner_option(self):\r\n        options = [self.vote1, self.vote2, self.vote3, self.vote4]\r\n        max_votes = max(options)\r\n        winner_index = options.index(max_votes)\r\n        if options.count(max_votes) &gt; 1:\r\n            return \"It's a tie\"\r\n        else:\r\n            if winner_index == 0:\r\n                return self.option1\r\n            elif winner_index == 1:\r\n                return self.option2\r\n            elif winner_index == 2:\r\n                return self.option3\r\n            elif winner_index == 3:\r\n                return self.option4\r\n        return\r\n\r\n    def __str__(self) -&gt; str:\r\n        return self.ques\r\n    \r\nclass Voted(models.Model):\r\n    user = models.ForeignKey(User, on_delete=models.CASCADE)\r\n    voted_question = models.ForeignKey(Questions, on_delete=models.CASCADE)\r\n\r\nclass UserProfile(models.Model):\r\n    user = models.OneToOneField(User, on_delete=models.CASCADE)\r\n    age = models.PositiveIntegerField(validators=[MinValueValidator(0)])<\/pre>\n<p>To create the above field in a database, run the following commands as follows:<\/p>\n<ul>\n<li>Py manage.py makemigrations<\/li>\n<li>Py manage.py migrate<\/li>\n<\/ul>\n<p>7. 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=\"container\"&gt;\r\n        &lt;h1&gt;&lt;u&gt;DataFlair Voting System&lt;\/u&gt;&lt;\/h1&gt;\r\n        &lt;div class=\"form-container\"&gt;\r\n            &lt;h1&gt;Registration&lt;\/h1&gt;\r\n            &lt;form action=\"{% url 'registration' %}\" method=\"post\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" placeholder=\"Name\" name=\"uname\"&gt;\r\n                &lt;input type=\"email\" placeholder=\"Email\" name=\"email\"&gt;\r\n                &lt;input type=\"text\" placeholder=\"Age\" name=\"age\"&gt;\r\n                &lt;input type=\"password\" placeholder=\"Password\" name=\"passw\"&gt;\r\n                &lt;input type=\"password\" placeholder=\"Confirm Password\" name=\"cpass\"&gt;\r\n                &lt;button type=\"submit\"&gt;Register&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n            &lt;p&gt;Already registered? &lt;a href=\"{% url 'index' %}\"&gt;click here&lt;\/a&gt;&lt;\/p&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['uname']\r\n        email = request.POST['email']\r\n        password = request.POST['passw']\r\n        cpassword = request.POST['cpass']\r\n        age = int(request.POST['age'])  # Convert age to an integer\r\n\r\n        if password == cpassword:\r\n            new_user = User.objects.create(\r\n            username = username,\r\n            email = email,\r\n            )\r\n            new_user.set_password(password)\r\n            new_user.save()\r\n\r\n            return redirect(\"index\")\r\n        return<\/pre>\n<p><strong>Urls.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">path(\"register\", views.register, name=\"register\"),\r\npath(\"registration\", views.Registration, name=\"registration\"),<\/pre>\n<p>8. 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=\"container\"&gt;\r\n        &lt;h1&gt;&lt;u&gt;DataFlair Voting System&lt;\/u&gt;&lt;\/h1&gt;\r\n        &lt;div class=\"form-container\"&gt;\r\n            &lt;h1&gt;Login&lt;\/h1&gt;\r\n            &lt;form action=\"{% url 'login' %}\" method=\"post\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" placeholder=\"Username\" name=\"uname\"&gt;\r\n                &lt;input type=\"password\" placeholder=\"Password\" name=\"password\"&gt;\r\n                &lt;button type=\"submit\"&gt;Login&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n            &lt;p&gt;Not registered? &lt;a href=\"{% url 'register' %}\"&gt;click here&lt;\/a&gt;&lt;\/p&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 Loginview(request):\r\n    if request.method == \"POST\":\r\n        username = request.POST['uname']\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            return HttpResponse(\"invalid credentials\")<\/pre>\n<p><strong>Urls.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">path(\"login\", views.Loginview, name=\"login\"),\r\n\r\n<\/pre>\n<p>9. Create a main page where voting can be done(one user can vote one time only).<br \/>\n<strong>templates\/app -&gt; votingpage.html<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;center&gt;\r\n        &lt;h3 style=\"color: tomato;\"&gt;\r\n            {% if messages %}\r\n            {% for message in messages %}\r\n            &lt;div&gt;{{ message }}&lt;\/div&gt;\r\n            {% endfor %}\r\n            {% endif %}\r\n        &lt;\/h3&gt;\r\n    &lt;\/center&gt;\r\n    &lt;br&gt;&lt;br&gt;\r\n  {% for item in new_ques %}\r\n    &lt;div class=\"container\"&gt;\r\n        &lt;form method=\"post\" action=\"{% url 'votingpage' pk=item.pk %}\"&gt;\r\n            {% csrf_token %}\r\n            &lt;h2&gt;{{ item.ques }}&lt;\/h2&gt;\r\n            &lt;label&gt;&lt;input type=\"radio\" name=\"selected_option\" value=\"1\"&gt;{{ item.option1 }}&lt;\/label&gt;&lt;br&gt;\r\n            &lt;label&gt;&lt;input type=\"radio\" name=\"selected_option\" value=\"2\"&gt;{{ item.option2 }}&lt;\/label&gt;&lt;br&gt;\r\n            &lt;label&gt;&lt;input type=\"radio\" name=\"selected_option\" value=\"3\"&gt;{{ item.option3 }}&lt;\/label&gt;&lt;br&gt;\r\n            &lt;label&gt;&lt;input type=\"radio\" name=\"selected_option\" value=\"4\"&gt;{{ item.option4 }}&lt;\/label&gt;&lt;br&gt;\r\n            &lt;h4&gt;Total Votes: {{item.total_votes}}&lt;\/h4&gt;\r\n            {% if item.is_closed %}\r\n            &lt;p&gt;&lt;strong&gt;Winner: {{ item.get_winner_option }}&lt;\/strong&gt;&lt;\/p&gt;\r\n            &lt;button class=\"vote-button\" type=\"button\" disabled&gt;\r\n                Voting Closed\r\n            &lt;\/button&gt;\r\n            {% else %}\r\n            &lt;button class=\"vote-button\" type=\"submit\"&gt;\r\n                {% if user_profile.age &gt; 18 %}\r\n                Vote Now\r\n                {% else %}\r\n                Not allowed\r\n                {% endif %}\r\n            &lt;\/button&gt;\r\n            {% endif %}\r\n        &lt;\/form&gt;\r\n        &lt;br&gt;\r\n    &lt;\/div&gt;\r\n    {% endfor %}<\/pre>\n<p><strong>Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">@login_required(login_url=\"login\")\r\ndef Voting(request, pk):\r\n    user = request.user\r\n    ques = get_object_or_404(Questions, pk=pk)\r\n    \r\n    # Check if the user is below 18 years old\r\n    user_profile = UserProfile.objects.get(user=user)\r\n    if user_profile.age &lt; 18:\r\n        messages.warning(request, \"Voters below 18 years of age are not allowed to vote.\")\r\n        return redirect(\"votingpage\")\r\n\r\n    # Check if the user has already voted for this question\r\n    if Voted.objects.filter(user=user, voted_question=ques).exists():\r\n        messages.warning(request, \"You have already voted for this question.\")\r\n        return redirect(\"already\") \r\n    else:\r\n        selected_option = request.POST.get('selected_option')\r\n        if selected_option in ['1', '2', '3', '4']:\r\n            setattr(ques, f'vote{selected_option}', getattr(ques, f'vote{selected_option}') + 1)\r\n            ques.save()\r\n            Voted.objects.create(user=user, voted_question=ques)\r\n            messages.success(request, \"Your vote has been recorded.\")\r\n        else:\r\n            messages.warning(request, \"Invalid vote selection.\")\r\n\r\n        return redirect('show')\r\n\r\n@login_required(login_url=\"login\")\r\ndef show(request):\r\n    new_ques = Questions.objects.all()\r\n   \r\n\r\n    # Check if the user's age is less than 18 and show a warning message\r\n    user_profile = UserProfile.objects.get(user=request.user)\r\n    if user_profile.age &lt; 18:\r\n        messages.warning(request, \"Voter below 18 age group is not allowed.\")\r\n\r\n    return render(request, \"app\/votingpage.html\", {\"new_ques\": new_ques, \"user_profile\": user_profile})<\/pre>\n<p><strong>Urls.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">path(\"home\", views.home, name=\"home\"),\r\npath(\"votingpage\/&lt;int:pk&gt;\", views.Voting, name=\"votingpage\"),\r\npath(\"showques\", views.show, name=\"show\"),<\/pre>\n<p>10. For logout process<br \/>\n<strong>Views.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">@login_required(login_url=\"login\")\r\ndef signout(request):\r\n    logout(request)\r\n    return redirect(\"index\")<\/pre>\n<p><strong>Urls.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">path(\"logout\", views.signout, name=\"logout\")\r\n<\/pre>\n<h3>Explanation of the above snippets:<\/h3>\n<p><strong>Certainly! Here&#8217;s an explanation of each view in the provided code:<\/strong><\/p>\n<h4 class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">1. Index(request):<\/h4>\n<p>This view renders the login page (login.html).<\/p>\n<h4 class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">2. register(request):<\/h4>\n<p>This view renders the registration page (registration.html).<\/p>\n<h4 class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">3. Registration(request):<\/h4>\n<ul>\n<li>This view handles the registration process when the registration form is submitted.<\/li>\n<li>It first checks if the passwords provided by the user match.<\/li>\n<li>If the passwords match, a new User object is created with the provided username and email.<\/li>\n<li>The password is set and encrypted using the set_password method.<\/li>\n<li>The new user is saved to the database, and the user is redirected to the login page (index).<\/li>\n<\/ul>\n<h4 class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">4. Loginview(request):<\/h4>\n<ul>\n<li>This view handles the login process when the login form is submitted.<\/li>\n<li>It retrieves the username and password entered by the user.<\/li>\n<li>The authenticate function is used to verify the credentials. If the authentication is successful, the user is logged in using the login function, and they are redirected to the &#8220;show&#8221; page.<\/li>\n<li>If the authentication fails, an &#8220;invalid credentials&#8221; message is displayed.<\/li>\n<\/ul>\n<h4 class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">5. home(request):<\/h4>\n<ul>\n<li>This view renders the main page (votingpage.html) after the user has successfully logged in.<\/li>\n<li>The @login_required decorator ensures that only authenticated users can access this page. If a user is not logged in, they are redirected to the login page.<\/li>\n<\/ul>\n<h4 class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">6. Voting(request, pk):<\/h4>\n<ul>\n<li>This view handles the process of voting for a specific question.<\/li>\n<li>It first retrieves the authenticated user and the question (specified by its primary key pk) using get_object_or_404.<\/li>\n<li>It checks if the user has already voted for the question by searching for an existing record in the Voted model.<\/li>\n<li>If the user has not voted for the question, the vote count for the question is incremented, and the vote is saved.<\/li>\n<li>A new record is created in the Voted model to indicate that the user has voted for that question.<\/li>\n<li>The user is then redirected to the &#8220;show&#8221; page.<\/li>\n<\/ul>\n<h4 class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">7. show(request):<\/h4>\n<ul>\n<li>This view retrieves all the questions from the Questions model and renders the &#8220;votingpage.html&#8221; template.<\/li>\n<li>The retrieved questions are passed to the template as the context variable new_ques.<\/li>\n<\/ul>\n<h4 class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">8. signout(request):<\/h4>\n<ul>\n<li>This view handles the logout process.<\/li>\n<li>The logout function is called to log out the user.<\/li>\n<li>The user is then redirected to the login page (index).<\/li>\n<\/ul>\n<p>These views, along with the corresponding URL patterns defined in the urlpatterns list, form the routing and logic for the online voting system.<\/p>\n<p><strong>Here is the complete code for Python Django Online Voting System as follows:<\/strong><\/p>\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&gt;\r\n\r\n&lt;head&gt;\r\n    &lt;title&gt;Registration&lt;\/title&gt;\r\n    &lt;style&gt;\r\n        body {\r\n            background-color: #ffffff;\r\n            display: flex;\r\n            justify-content: center;\r\n            align-items: center;\r\n            height: 100vh;\r\n            margin: 0;\r\n        }\r\n\r\n        .container {\r\n            background-color: #ffffff;\r\n            border-radius: 5px;\r\n            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);\r\n            padding: 20px;\r\n            width: 300px;\r\n        }\r\n\r\n        h1 {\r\n            text-align: center;\r\n        }\r\n\r\n        form {\r\n            display: flex;\r\n            flex-direction: column;\r\n        }\r\n\r\n        input[type=\"text\"],\r\n        input[type=\"email\"],\r\n        input[type=\"password\"] {\r\n            padding: 10px;\r\n            margin-bottom: 10px;\r\n            border: 1px solid #ccc;\r\n            border-radius: 4px;\r\n        }\r\n\r\n        button {\r\n            padding: 10px;\r\n            background-color: #4caf50;\r\n            color: #ffffff;\r\n            border: none;\r\n            border-radius: 4px;\r\n            cursor: pointer;\r\n        }\r\n\r\n        button:hover {\r\n            background-color: #45a049;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;div class=\"container\"&gt;\r\n        &lt;h1&gt;&lt;u&gt;DataFlair Voting System&lt;\/u&gt;&lt;\/h1&gt;\r\n        &lt;div class=\"form-container\"&gt;\r\n            &lt;h1&gt;Registration&lt;\/h1&gt;\r\n            &lt;form action=\"{% url 'registration' %}\" method=\"post\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" placeholder=\"Name\" name=\"uname\"&gt;\r\n                &lt;input type=\"email\" placeholder=\"Email\" name=\"email\"&gt;\r\n                &lt;input type=\"text\" placeholder=\"Age\" name=\"age\"&gt;\r\n                &lt;input type=\"password\" placeholder=\"Password\" name=\"passw\"&gt;\r\n                &lt;input type=\"password\" placeholder=\"Confirm Password\" name=\"cpass\"&gt;\r\n                &lt;button type=\"submit\"&gt;Register&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n            &lt;p&gt;Already registered? &lt;a href=\"{% url 'index' %}\"&gt;click here&lt;\/a&gt;&lt;\/p&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; login.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;Login&lt;\/title&gt;\r\n    &lt;style&gt;\r\n        body {\r\n            background-color: #ffffff;\r\n            display: flex;\r\n            justify-content: center;\r\n            align-items: center;\r\n            height: 100vh;\r\n            margin: 0;\r\n        }\r\n\r\n        .container {\r\n            background-color: #ffffff;\r\n            border-radius: 5px;\r\n            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);\r\n            padding: 20px;\r\n            width: 300px;\r\n        }\r\n\r\n        h1 {\r\n            text-align: center;\r\n        }\r\n\r\n        form {\r\n            display: flex;\r\n            flex-direction: column;\r\n        }\r\n\r\n        input[type=\"text\"],\r\n        input[type=\"password\"] {\r\n            padding: 10px;\r\n            margin-bottom: 10px;\r\n            border: 1px solid #ccc;\r\n            border-radius: 4px;\r\n        }\r\n\r\n        button {\r\n            padding: 10px;\r\n            background-color: #4caf50;\r\n            color: #ffffff;\r\n            border: none;\r\n            border-radius: 4px;\r\n            cursor: pointer;\r\n        }\r\n\r\n        button:hover {\r\n            background-color: #45a049;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;div class=\"container\"&gt;\r\n        &lt;h1&gt;&lt;u&gt;DataFlair Voting System&lt;\/u&gt;&lt;\/h1&gt;\r\n        &lt;div class=\"form-container\"&gt;\r\n            &lt;h1&gt;Login&lt;\/h1&gt;\r\n            &lt;form action=\"{% url 'login' %}\" method=\"post\"&gt;\r\n                {% csrf_token %}\r\n                &lt;input type=\"text\" placeholder=\"Username\" name=\"uname\"&gt;\r\n                &lt;input type=\"password\" placeholder=\"Password\" name=\"password\"&gt;\r\n                &lt;button type=\"submit\"&gt;Login&lt;\/button&gt;\r\n            &lt;\/form&gt;\r\n            &lt;p&gt;Not registered? &lt;a href=\"{% url 'register' %}\"&gt;click here&lt;\/a&gt;&lt;\/p&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; votingpage.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;link rel=\"stylesheet\" type=\"text\/css\" href=\"style.css\"&gt;\r\n    &lt;style&gt;\r\n        nav {\r\n            background-color: #f2f2f2;\r\n            height: 60px;\r\n            display: flex;\r\n            justify-content: space-between;\r\n            align-items: center;\r\n            padding: 0 20px;\r\n        }\r\n\r\n        .logo img {\r\n            height: 40px;\r\n        }\r\n\r\n        .username {\r\n            font-size: 18px;\r\n        }\r\n\r\n        .container {\r\n            max-width: 400px;\r\n            margin: 0 auto;\r\n            padding: 20px;\r\n            background-color: #f2f2f2;\r\n            border-radius: 5px;\r\n        }\r\n\r\n        h2 {\r\n            text-align: center;\r\n            margin-bottom: 20px;\r\n        }\r\n\r\n        .option {\r\n            display: flex;\r\n            align-items: center;\r\n            margin-bottom: 10px;\r\n        }\r\n\r\n        input[type=\"radio\"] {\r\n            margin-right: 10px;\r\n        }\r\n\r\n        label {\r\n            font-size: 16px;\r\n        }\r\n\r\n        .vote-button {\r\n            display: block;\r\n            width: 100%;\r\n            margin-top: 20px;\r\n            padding: 10px;\r\n            font-size: 16px;\r\n            text-align: center;\r\n            background-color: #4caf50;\r\n            color: white;\r\n            border: none;\r\n            border-radius: 5px;\r\n            cursor: pointer;\r\n        }\r\n\r\n        .vote-button:hover {\r\n            background-color: #45a049;\r\n        }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n    &lt;nav&gt;\r\n        &lt;div class=\"logo\"&gt;\r\n            &lt;h1&gt;DataFlair Voting System&lt;\/h1&gt;\r\n        &lt;\/div&gt;\r\n        &lt;div class=\"username\"&gt;\r\n            {% if user.is_authenticated %}\r\n            &lt;span&gt;Welcome, {{ user.username }} &lt;a href=\"{% url 'logout' %}\"&gt;(logout)&lt;\/a&gt;&lt;\/span&gt;\r\n            {% endif %}\r\n        &lt;\/div&gt;\r\n    &lt;\/nav&gt;\r\n    &lt;br&gt;&lt;br&gt;\r\n    {% for item in new_ques %}\r\n    &lt;div class=\"container\"&gt;\r\n        &lt;form method=\"post\" action=\"{% url 'votingpage' pk=item.pk %}\"&gt;\r\n            {% csrf_token %}\r\n        &lt;h2&gt;{{ item.ques }}&lt;\/h2&gt;\r\n            &lt;button class=\"vote-button\" type=\"submit\"&gt;{% if vote.is_valid %} voted {% else %} vote {% endif %}&lt;\/button&gt;\r\n        &lt;\/form&gt;\r\n        &lt;br&gt;\r\n    &lt;\/div&gt;\r\n    {% endfor %}\r\n   \r\n&lt;\/body&gt;\r\n\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Views.py\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.shortcuts import get_object_or_404, render, redirect, HttpResponse\r\nfrom django.contrib.auth.models import User\r\nfrom django.contrib.auth.decorators import login_required\r\nfrom django.contrib.auth import login, authenticate, logout\r\nfrom .models import Questions, Voted, UserProfile\r\nfrom django.contrib import messages\r\n# Create your views here.\r\ndef Index(request):\r\n    return render(request, \"app\/login.html\")\r\n\r\ndef register(request):\r\n    return render(request, \"app\/registration.html\")\r\n\r\n@login_required(login_url=\"login\")\r\ndef successfully(request):\r\n    return render(request, \"app\/successfully_voted.html\")\r\n\r\n@login_required(login_url=\"login\")\r\ndef already(request):\r\n    return render(request, \"app\/already_voted.html\")\r\n\r\n\r\ndef Registration(request):\r\n    if request.method == \"POST\":\r\n        username = request.POST['uname']\r\n        email = request.POST['email']\r\n        password = request.POST['passw']\r\n        cpassword = request.POST['cpass']\r\n        age = int(request.POST['age'])  # Convert age to an integer\r\n\r\n        if password == cpassword:\r\n            new_user = User.objects.create(\r\n                username=username,\r\n                email=email,\r\n            )\r\n            new_user.set_password(password)\r\n            new_user.save()\r\n\r\n            # Save the age information in the UserProfile model\r\n            UserProfile.objects.create(user=new_user, age=age)\r\n\r\n            return redirect(\"index\")\r\n        return render(request, \"app\/registration.html\")\r\n   \r\ndef Loginview(request):\r\n    if request.method == \"POST\":\r\n        username = request.POST['uname']\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            return HttpResponse(\"invalid credentials\")\r\n   \r\n@login_required(login_url=\"login\")\r\ndef home(request):\r\n    return render(request, \"app\/votingpage.html\")\r\n\r\n@login_required(login_url=\"login\")\r\ndef Voting(request, pk):\r\n    user = request.user\r\n    ques = get_object_or_404(Questions, pk=pk)\r\n   \r\n    # Check if the user is below 18 years old\r\n    user_profile = UserProfile.objects.get(user=user)\r\n    if user_profile.age &lt; 18:\r\n        messages.warning(request, \"Voters below 18 years of age are not allowed to vote.\")\r\n        return render(request, \"app\/votingpage.html\")\r\n\r\n    # Check if the user has already voted for this question\r\n    if Voted.objects.filter(user=user, voted_question=ques).exists():\r\n        return redirect(\"successfully\")\r\n    else:\r\n        ques.vote += 1\r\n        ques.save()\r\n        Voted.objects.create(user=user, voted_question=ques)\r\n        return redirect('already')\r\n\r\n@login_required(login_url=\"login\")\r\ndef show(request):\r\n    new_ques = Questions.objects.all()\r\n   \r\n\r\n    # Check if the user's age is less than 18 and show a warning message\r\n    user_profile = UserProfile.objects.get(user=request.user)\r\n    if user_profile.age &lt; 18:\r\n        messages.warning(request, \"Voter below 18 age group is not allowed.\")\r\n\r\n    return render(request, \"app\/votingpage.html\", {\"new_ques\": new_ques, \"user_profile\": user_profile})\r\n\r\ndef signout(request):\r\n    logout(request)\r\n    return redirect(\"index\")<\/pre>\n<p><strong>Urls.py<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.urls import path,include\r\nfrom . import views\r\n\r\nurlpatterns = [\r\n    path(\"\", views.Index, name=\"index\"),\r\n    path(\"register\", views.register, name=\"register\"),\r\n    path(\"registration\", views.Registration, name=\"registration\"),\r\n    path(\"home\", views.home, name=\"home\"),\r\n    path(\"login\", views.Loginview, name=\"login\"),\r\n    path(\"votingpage\/&lt;int:pk&gt;\", views.Voting, name=\"votingpage\"),\r\n    path(\"showques\", views.show, name=\"show\"),\r\n    path(\"logout\", views.signout, name=\"logout\"),\r\n    path(\"successfully\", views.successfully, name=\"successfully\"),\r\n    path(\"already\", views.already, name=\"already\")\r\n]\r\n<\/pre>\n<h3>Python Django Online Voting System Output<\/h3>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-voting-system-login-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120628 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-voting-system-login-output.webp\" alt=\"online voting system login output\" width=\"1841\" height=\"1005\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-voting-system-registration-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120629 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-voting-system-registration-output.webp\" alt=\"online voting system registration output\" width=\"1845\" height=\"1005\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-voting-system-project-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120627 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/online-voting-system-project-output.webp\" alt=\"online voting system project output\" width=\"1845\" height=\"1005\" \/><\/a><\/p>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/voting-page-below-age-18.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120630 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/voting-page-below-age-18.webp\" alt=\"voting page below age 18\" width=\"1841\" height=\"1004\" \/><\/a><\/h4>\n<h4>Admin panel<\/h4>\n<p>Now how would we add data, delete, and update to the user side? Let\u2019s come to the django inbuilt admin panel. So here are the details of the same:<\/p>\n<p>1. Once you have your Django project set up and have created your models, you can use the admin panel to add data easily. Follow these steps:<br \/>\n2. Run python manage.py createsuperuser to create an admin user who can access the admin panel. Start the development server using python manage.py runserver. Open your browser and go to the admin panel URL (usually http:\/\/127.0.0.1:8000\/admin\/) Log in using the superuser credentials you created.<br \/>\n3. Then, Go to admin.py and add the following thing as follows:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from django.contrib import admin\r\nfrom .models import YourModelName\r\n \r\nadmin.site.register(YourModelName)\r\n<\/pre>\n<p><strong>Note:<\/strong> To display the model on the admin panel, you need to follow the third point.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/admin-panel-show-question.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120631 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/admin-panel-show-question.webp\" alt=\"admin panel show question\" width=\"1845\" height=\"1005\" \/><\/a><\/p>\n<h3><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/total-votes-admin-page.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-120632 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/09\/total-votes-admin-page.webp\" alt=\"total votes admin page\" width=\"1849\" height=\"1005\" \/><\/a><\/h3>\n<h3>Summary:<\/h3>\n<p>The provided code represents a basic online voting system implemented using Django framework. It includes registration, login, and voting functionalities. Users can register, log in, view and vote on questions. The system ensures authentication, prevents duplicate votes, and tracks user activity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>An online voting system, also known as e-voting, is a digital platform that allows eligible voters to cast their votes remotely using the internet. It is a modern alternative to traditional paper-based voting methods.&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":118540,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19149],"tags":[28066,19201,28303,21674,28068,28067,28065,21613],"class_list":["post-118536","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-django","tag-django-online-voting-system-project","tag-django-project","tag-django-project-for-practice","tag-django-project-ideas","tag-online-voting-system","tag-online-voting-system-project","tag-python-django-online-voting-system-project","tag-python-django-project"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Django Project \u2013 Online Voting System - DataFlair<\/title>\n<meta name=\"description\" content=\"An online voting system, also known as e-voting, is a digital platform that allows eligible voters to cast their votes remotely using the internet.\" \/>\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-voting-system\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Django Project \u2013 Online Voting System - DataFlair\" \/>\n<meta property=\"og:description\" content=\"An online voting system, also known as e-voting, is a digital platform that allows eligible voters to cast their votes remotely using the internet.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/\" \/>\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-10-30T13:30:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T06:31:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/08\/pyhton-django-online-voting-system.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 Project \u2013 Online Voting System - DataFlair","description":"An online voting system, also known as e-voting, is a digital platform that allows eligible voters to cast their votes remotely using the internet.","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-voting-system\/","og_locale":"en_US","og_type":"article","og_title":"Python Django Project \u2013 Online Voting System - DataFlair","og_description":"An online voting system, also known as e-voting, is a digital platform that allows eligible voters to cast their votes remotely using the internet.","og_url":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2023-10-30T13:30:23+00:00","article_modified_time":"2026-06-01T06:31:24+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/08\/pyhton-django-online-voting-system.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-voting-system\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"Python Django Project \u2013 Online Voting System","datePublished":"2023-10-30T13:30:23+00:00","dateModified":"2026-06-01T06:31:24+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/"},"wordCount":1563,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/08\/pyhton-django-online-voting-system.webp","keywords":["django online voting system project","Django Project","django project for practice","Django Project Ideas","online voting system","online voting system project","python django online voting system project","python django project"],"articleSection":["Django Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/","url":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/","name":"Python Django Project \u2013 Online Voting System - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/08\/pyhton-django-online-voting-system.webp","datePublished":"2023-10-30T13:30:23+00:00","dateModified":"2026-06-01T06:31:24+00:00","description":"An online voting system, also known as e-voting, is a digital platform that allows eligible voters to cast their votes remotely using the internet.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/08\/pyhton-django-online-voting-system.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/08\/pyhton-django-online-voting-system.webp","width":1200,"height":628,"caption":"python django online voting system"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-django-online-voting-system\/#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 Project \u2013 Online Voting System"}]},{"@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\/118536","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=118536"}],"version-history":[{"count":8,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/118536\/revisions"}],"predecessor-version":[{"id":148578,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/118536\/revisions\/148578"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/118540"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=118536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=118536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=118536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}