Voting Web Application using Django Framework
Pollster is a web application built using Django framework. It facilitates conducting polls consisting of questions and choices, allowing users to vote for their preferred choices. The application also provides result visualization for users to track the total votes for specific questions.
-
Setting Up the Environment:
- Create an empty folder named
pollster_project
. - Set up a virtual environment using
pipenv
. - Install Django within the virtual environment.
- Create an empty folder named
-
Initializing Django Project:
- Create a Django project named
pollster
. - Create an app named
polls
within the project.
- Create a Django project named
-
Define Models:
- Define two models,
Question
andChoice
, in themodels.py
file. Question
contains fields for question text and publication date.Choice
contains fields for choice text, votes, and a foreign key relationship withQuestion
.
- Define two models,
-
Register Apps:
- Include the
polls
app in theINSTALLED_APPS
list insettings.py
.
- Include the
-
Migrations and Database Setup:
- Generate and apply migrations to create database tables for models.
-
Create Superuser:
- Create a superuser to access the admin panel.
-
Customize Admin Interface:
- Customize admin site header, title, and index title.
- Register models and inline choices for administration.
-
Define Views:
- Implement views for displaying questions, voting, viewing details, and displaying results.
- Utilize Django's built-in
render
function for rendering templates.
-
Define URLs:
- Define URL patterns for views in the
urls.py
file within thepolls
app.
- Define URL patterns for views in the
-
Frontend Layout:
- Create base HTML layout including navigation bar.
- Create templates for index, detail, and results pages.
-
Configure Template Path:
- Configure the template directory path in Django settings.
-
Create Pages App:
- Create a separate app named
pages
for the landing page.
- Create a separate app named
-
Define Landing Page View and Template:
- Implement a view to render the landing page.
- Create an HTML template for the landing page.
- Configure URLs:
- Define URL patterns for both
polls
andpages
apps in the mainurls.py
.
- Define URL patterns for both
-
Admin Login:
- Access the admin panel using the provided URL.
- Log in using superuser credentials.
-
Add Questions:
- Add questions and choices via the admin interface.
-
Access Landing Page:
- Visit the landing page of the application.
- Navigate to available polls.
-
Voting Process:
- Select a question and vote for a choice.
- View the voting results.
This project can serve as a foundation for implementing online voting systems in various domains. Future enhancements could include additional features based on specific requirements, such as user authentication, result analysis, and sharing options.
You can copy this structure into a Markdown file named README.md
in your GitHub repository to provide comprehensive documentation for your project. Make sure to replace placeholders with actual content as needed.