0% found this document useful (0 votes)
12 views7 pages

polling website

The document outlines the development of a Django-based polling website that allows users to register, vote, and manage polls. Key features include user authentication, poll management, and an admin panel for content management. The project aims to create an interactive platform for community engagement through polls, utilizing technologies like Django, HTML, and SQLite.

Uploaded by

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

polling website

The document outlines the development of a Django-based polling website that allows users to register, vote, and manage polls. Key features include user authentication, poll management, and an admin panel for content management. The project aims to create an interactive platform for community engagement through polls, utilizing technologies like Django, HTML, and SQLite.

Uploaded by

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

PYTHON AND WEB PROGRAMMING(202045612) G.

H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY

POLLING WEBSITE
Introduction

• Django polling website is a full featured polling platform . You have to


register in this app to show the polls and to vote. If you already voted you
can not vote again. Only the owner of a poll can add poll , edit poll,
update poll, delete poll , add choice, update choice, delete choice and end
a poll. If a poll is ended it can not be voted. Ended poll only shows user
the final result of the poll. .

• The main goal of the project is to create a simple polling platform where
user can vote their choices content , interact with polls and manage their
personal accounts.

❖ Technologies Used:
• Backend: Django (Python framework)
• Frontend: HTML, CSS
• Database: SQLite (or PostgreSQL for production)
• Authentication: Django’s built-in authentication system
• Deployment: Heroku or any other hosting platform (for live deployment)

❖ Features and functions:

• User Authentication:
Users can register, log in, and manage their profiles. The authentication system
leverages Django’s built-in tools for user management, including password hashing
and session management.

• Vote Section:
Registered users can leave their vote on polls . This fosters interaction and
community engagement. Admins can modify and delete polls.

• Admin Panel:

GUIDED BY: Jay Pandya SIR

MADE BY: Yash Patel (12202110501077)


PYTHON AND WEB PROGRAMMING(202045612) G.H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY

The Django admin interface is used for editing polls , adding choices, and
dates. Admins can add, edit, or delete content, and manage user permissions.

❖ Poll Management:
• Create Polls: Logged-in users can create polls with questions and options.
• View Polls: All users can view polls sorted by date, category, or
popularity.
• Update Polls: Authors can edit their own polls.
• Delete Polls: Authors can delete their own polls.
• Vote on Polls: Users can vote once on active polls.
• Poll Results: Users can view poll results after voting or poll closure.
• Pagination: Poll lists are paginated for easier navigation.

❖ System Design
• Django MVC (Model-View-Controller) Architecture:
Django follows the MVT (Model-View-Template) architecture, which separates
the business logic, user interface, and data models:
• Model: Defines the structure of the data (e.g., BlogPost, Comment, User).
• View: Handles user interaction and contains the logic for displaying data.
• Template: HTML files responsible for the layout of pages, incorporating
dynamic data passed from views.

Conclusion
The Django-powered polling website offers a robust platform for creating and managing
polls with user authentication and easy poll management. Future improvements will
enhance its functionality and user experience.

Main login page.


ef login_user(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username=username, password=password)

GUIDED BY: Jay Pandya SIR

MADE BY: Yash Patel (12202110501077)


PYTHON AND WEB PROGRAMMING(202045612) G.H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY

if user is not None:


login(request, user)
redirect_url = request.GET.get('next', 'home')
return redirect(redirect_url)
else:
messages.error(request, "Username Or Password is incorrect!",
extra_tags='alert alert-warning alert-dismissible fade show')

return render(request, 'accounts/login.html')

def logout_user(request):
logout(request)
return redirect('home')

def create_user(request):
if request.method == 'POST':
check1 = False
check2 = False
check3 = False
form = UserRegistrationForm(request.POST)
if form.is_valid():
username = form.cleaned_data['username']
password1 = form.cleaned_data['password1']
password2 = form.cleaned_data['password2']
email = form.cleaned_data['email']

if password1 != password2:
check1 = True
messages.error(request, 'Password did not match!',
extra_tags='alert alert-warning alert-dismissible fade show')
if User.objects.filter(username=username).exists():
check2 = True
messages.error(request, 'Username already exists!',
extra_tags='alert alert-warning alert-dismissible fade show')

GUIDED BY: Jay Pandya SIR

MADE BY: Yash Patel (12202110501077)


PYTHON AND WEB PROGRAMMING(202045612) G.H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY

if User.objects.filter(email=email).exists():
check3 = True
messages.error(request, 'Email already registered!',
extra_tags='alert alert-warning alert-dismissible fade show')

if check1 or check2 or check3:


messages.error(
request, "Registration Failed!", extra_tags='alert alert-warning alert-
dismissible fade show')
return redirect('accounts:register')
else:
user = User.objects.create_user(
username=username, password=password1, email=email)
messages.success(
request, f'Thanks for registering {user.username}.', extra_tags='alert
alert-success alert-dismissible fade show')
return redirect('accounts:login')
else:
form = UserRegistrationForm()
return render(request, 'accounts/register.html', {'form': form})

GUIDED BY: Jay Pandya SIR

MADE BY: Yash Patel (12202110501077)


PYTHON AND WEB PROGRAMMING(202045612) G.H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY

authorization page

{% extends 'base.html' %}{% load static %}{% block custom_css %}<link


rel="stylesheet" href="{% static 'css/home_style.css' %}">{% endblock custom_css %}
{% block content %}<div class="container"><div class="row"><div class="col"><div
id="home-content"><h1>PollMe - Get Started!</h1><h3>Your Voice
Matters!</h3><hr><a class="btn btn-light btn-lg" href="{% url 'polls:list' %}"
role="button">Get Started !</a></div></div></div></div>{% endblock content %}

GUIDED BY: Jay Pandya SIR

MADE BY: Yash Patel (12202110501077)


PYTHON AND WEB PROGRAMMING(202045612) G.H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY

New poll

# views.py (in the polls app)


from django.shortcuts import render, redirect
from .models import Poll, Choice
from .forms import PollForm, ChoiceForm

def create_poll(request):
if request.method == 'POST':
poll_form = PollForm(request.POST)
choice_form = ChoiceForm(request.POST)

GUIDED BY: Jay Pandya SIR

MADE BY: Yash Patel (12202110501077)


PYTHON AND WEB PROGRAMMING(202045612) G.H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY

if poll_form.is_valid() and choice_form.is_valid():


# Create the poll
poll = poll_form.save()
# Create a choice for the poll (assuming a poll has choices)
choice = choice_form.save(commit=False)
choice.poll = poll
choice.save()
return redirect('polls:list') # Redirect to a poll listing page
else:
poll_form = PollForm()
choice_form = ChoiceForm()

return render(request, 'polls/create_poll.html', {'poll_form': poll_form,


'choice_form': choice_form})

GUIDED BY: Jay Pandya SIR

MADE BY: Yash Patel (12202110501077)

You might also like