A simple and interactive polling web application built with Django. Users can view recent polls, vote on choices, and see real-time voting results.
This project was created while learning Django fundamentals including:
- Models
- Views
- Templates
- URL routing
- Forms and POST requests
- Generic class-based views
- Database queries
- Testing
- View latest published questions
- Vote on poll choices
- Display voting results dynamically
- Prevent duplicate form submissions using redirects
- Use Django generic views for cleaner architecture
- Model testing using Django TestCase
- SQLite database integration
- Python 3
- Django 6
- SQLite3
- HTML5
- Django Template Language (DTL)
polls/
│
├── migrations/
├── templates/
│ └── polls/
│ ├── index.html
│ ├── detail.html
│ └── results.html
│
├── admin.py
├── apps.py
├── models.py
├── tests.py
├── urls.py
└── views.pygit clone https://github.com/your-username/your-repository-name.gitcd your-repository-namepython -m venv venv
venv\Scripts\activatepython3 -m venv venv
source venv/bin/activatepip install djangoOr if you have a requirements file:
pip install -r requirements.txtpython manage.py migratepython manage.py createsuperuserFollow the prompts to create your admin account.
python manage.py runserverOpen your browser and visit:
http://127.0.0.1:8000/polls/Run Django tests using:
python manage.py testThis project includes model tests for validating question publication logic.
- User visits the polls homepage
- Latest questions are displayed
- User selects a question
- User votes for a choice
- Vote count is updated
- Results page displays updated vote counts
Used Django ORM to create:
- Question model
- Choice model
Implemented both:
- Function-based views
- Generic class-based views
Used Django Template Language for:
- Loops
- Variables
- URL template tags
- Conditional rendering
Handled form submission securely using:
{% csrf_token %}Created unit tests using Django TestCase.
Potential upgrades for the project:
- User authentication
- AJAX voting without page reload
- Poll expiration dates
- Charts and analytics
- REST API integration
- Tailwind CSS styling
- Search and filtering
- Docker deployment
This project is for educational and learning purposes.
Avishek Paudel
GitHub: https://github.com/AvishekPaudel