polling website
polling website
POLLING WEBSITE
Introduction
• 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)
• 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:
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.
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')
if User.objects.filter(email=email).exists():
check3 = True
messages.error(request, 'Email already registered!',
extra_tags='alert alert-warning alert-dismissible fade show')
authorization page
New poll
def create_poll(request):
if request.method == 'POST':
poll_form = PollForm(request.POST)
choice_form = ChoiceForm(request.POST)