Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A modern, responsive polling application built with Django.

Notifications You must be signed in to change notification settings

tonybnya/poll-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—³οΈ Django Polls Application

A modern, responsive polling application built with Django 5.2, featuring a beautiful UI with full CRUD functionality for creating, voting, and managing polls.

✨ Features

🎯 Core Polling Features

  • Create Polls - Create new polls with 2-4 choice options
  • Vote in Polls - Simple, intuitive voting interface
  • View Results - Real-time results with animated charts and statistics
  • Update Polls - Edit poll questions and choice options
  • Delete Polls - Safe deletion with confirmation and data integrity checks
  • Landing Page - Modern hero section with features showcase

🎨 User Interface

  • Modern Design - Clean, minimalist aesthetic with glass-morphism effects
  • Responsive Layout - Mobile-first design that works on all devices
  • Background Integration - Beautiful background image throughout the application
  • Smooth Animations - Micro-interactions, transitions, and loading states
  • Interactive Elements - Enhanced forms, buttons, and navigation
  • Accessibility - Semantic HTML5 structure with proper ARIA labels

πŸ”§ Technical Features

  • Django 5.2 - Latest Django framework with modern features
  • Class-Based Views - Follows Django best practices
  • Form Validation - Client-side and server-side validation
  • Error Handling - User-friendly error messages and feedback
  • Test Coverage - Comprehensive tests for all functionality
  • Database Integrity - Proper cascading deletes and relationship management

πŸ› οΈ Tech Stack

  • Backend: Django 5.2
  • Frontend: Modern CSS3 with JavaScript (ES6+)
  • Database: SQLite3 (development)
  • Package Manager: UV
  • Python: 3.14+
  • Styling: Custom CSS framework with CSS custom properties
  • Typography: Inter font family (Google Fonts)

πŸš€ Quick Start

Prerequisites

  • Python 3.14 or higher
  • UV package manager
  • Git

Installation

  1. Clone the repository

    git clone <repository-url>
    cd poll-app
  2. Set up environment

    # Install dependencies
    uv sync
    
    # Activate virtual environment
    source .venv/bin/activate
  3. Set up database

    # Apply migrations
    python manage.py migrate
    
    # Create superuser (optional)
    python manage.py createsuperuser
  4. Start development server

    python manage.py runserver
  5. Access the application Open your browser and navigate to http://127.0.0.1:8000/polls/

πŸ“– Usage Guide

🏠 Home Page

  • Hero Section: Eye-catching introduction to the polling platform
  • Features Section: Information about platform capabilities
  • Recent Polls: Quick access to latest available polls
  • Navigation: Easy access to create new polls

βž• Creating Polls

  1. Click "Create Poll" in the navigation bar
  2. Fill in the form:
    • Question: Enter your poll question (required)
    • Choices: Add 2-4 choice options (minimum 2 required)
  3. Submit: Click "Create Poll" to save

πŸ—³οΈ Voting in Polls

  1. Navigate to a poll from the home page
  2. Select your choice: Click on any radio button
  3. Cast your vote: Click "Cast Your Vote" button
  4. Confirmation: See success message and navigate to results

πŸ“Š Viewing Results

  1. Click "View Results" from poll detail or home page
  2. See statistics:
    • Individual choice vote counts
    • Visual progress bars showing percentages
    • Total votes and poll metadata
  3. Additional actions: Edit poll, vote again, or share results

✏️ Editing Polls

  1. Click "Edit Poll" from any poll detail/results page
  2. Modify the form:
    • Update question text
    • Add/remove/modify choice options
  3. Save changes: Click "Update Poll" button

πŸ—‘οΈ Deleting Polls

  1. Click "Delete Poll" from any poll detail/results page
  2. Review confirmation:
    • See poll details and vote counts
    • Warning about data loss if votes exist
  3. Confirm deletion: Click "Yes, Delete This Poll" button
  4. Confirmation: Redirect to home with success message

πŸ§ͺ Development

πŸ“‹ Commands

Environment Setup

# Activate virtual environment
source .venv/bin/activate

# Install dependencies
uv sync

# Update dependencies
uv add <package-name>

Database Operations

# Create migrations
python manage.py makemigrations

# Apply migrations
python manage.py migrate

# Reset database (development)
python manage.py flush

Development Server

# Start development server
python manage.py runserver

# Start on different port
python manage.py runserver 8001

Testing

# Run all tests
python manage.py test

# Run specific test class
python manage.py test polls.tests.QuestionModelTests

# Run with verbose output
python manage.py test --verbosity=2

# Run CRUD tests
python manage.py test polls.tests_crud

# Keep test database
python manage.py test --keepdb

Django Management

# Create new app
python manage.py startapp <app_name>

# Collect static files
python manage.py collectstatic

# Django shell
python manage.py shell

πŸ“ Project Structure

poll-app/
β”œβ”€β”€ core/                    # Django project configuration
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ asgi.py
β”‚   β”œβ”€β”€ settings.py
β”‚   β”œβ”€β”€ urls.py
β”‚   └── wsgi.py
β”œβ”€β”€ polls/                    # Main Django app
β”‚   β”œβ”€β”€ migrations/            # Database migrations
β”‚   β”œβ”€β”€ static/               # Static files
β”‚   β”‚   └── polls/
β”‚   β”‚       β”œβ”€β”€ css/         # Stylesheets
β”‚   β”‚       β”‚   β”œβ”€β”€ base.css
β”‚   β”‚       β”‚   β”œβ”€β”€ components.css
β”‚   β”‚       β”‚   └── responsive.css
β”‚   β”‚       β”œβ”€β”€ js/          # JavaScript files
β”‚   β”‚       β”‚   └── main.js
β”‚   β”‚       └── images/      # Images
β”‚   β”œβ”€β”€ templates/            # HTML templates
β”‚   β”‚   └── polls/
β”‚   β”‚       β”œβ”€β”€ base.html
β”‚   β”‚       β”œβ”€β”€ index.html
β”‚   β”‚       β”œβ”€β”€ detail.html
β”‚   β”‚       β”œβ”€β”€ results.html
β”‚   β”‚       β”œβ”€β”€ question_form.html
β”‚   β”‚       └── question_confirm_delete.html
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ admin.py              # Django admin configuration
β”‚   β”œβ”€β”€ apps.py               # App configuration
β”‚   β”œβ”€β”€ forms.py              # Django forms
β”‚   β”œβ”€β”€ models.py             # Database models
β”‚   β”œβ”€β”€ tests.py              # Original tests
β”‚   β”œβ”€β”€ tests_crud.py          # CRUD functionality tests
β”‚   β”œβ”€β”€ urls.py              # URL patterns
β”‚   └── views.py              # View functions/classes
β”œβ”€β”€ db.sqlite3               # SQLite database
β”œβ”€β”€ manage.py                # Django management script
β”œβ”€β”€ pyproject.toml            # UV dependencies
β”œβ”€β”€ uv.lock                  # Dependency lock file
└── README.md                # This file

🎨 Design System

Color Palette

  • Primary: #2ecc71 (green) - Main actions and highlights
  • Primary Dark: #27ae60 - Hover states
  • Secondary: #34495e (dark blue) - Text and borders
  • Accent: #e74c3c (red) - Warnings and delete actions
  • Background: #ffffff (white) - Main background

Typography

  • Font Family: Inter (Google Fonts)
  • Font Weights: 300 (light), 400 (normal), 500 (medium), 600 (semibold), 700 (bold)
  • Font Sizes: Responsive scale from 0.75rem to 3rem

Spacing System

  • Scale: 0.25rem, 0.5rem, 1rem, 1.5rem, 2rem, 3rem, 4rem
  • Consistent spacing using CSS custom properties

Component Patterns

  • Cards: Glass-morphism with backdrop blur
  • Buttons: Consistent hover states and transitions
  • Forms: Validation states and focus indicators
  • Navigation: Mobile-responsive with hamburger menu

πŸ§ͺ Testing

Test Structure

  • Unit Tests: Model methods and business logic
  • View Tests: All CRUD operations and edge cases
  • Integration Tests: Form submission and user workflows
  • Template Tests: UI rendering and response content

Running Tests

# All tests
python manage.py test

# Specific test class
python manage.py test polls.tests.QuestionModelTests

# Specific test method
python manage.py test polls.tests.QuestionModelTests.test_was_published_recently_with_future_question

# Coverage
coverage run --source='.' manage.py test
coverage report

Test Coverage Areas

  • βœ… Model Operations: CRUD, validation, relationships
  • βœ… View Rendering: Templates, status codes, context data
  • βœ… Form Processing: Valid/invalid data, edge cases
  • βœ… URL Routing: Correct view mapping, parameters
  • βœ… User Workflows: Complete create β†’ vote β†’ results β†’ update/delete flows

πŸ”§ Configuration

Environment Variables

# For production deployment
export DEBUG=False
export SECRET_KEY='your-secret-key-here'
export DATABASE_URL='sqlite:///path/to/production.db'

Settings Highlights

  • Debug Mode: Enabled for development
  • Static Files: Configured for production serving
  • Database: SQLite with proper migration support
  • Security: CSRF protection and secure defaults
  • Messages: User feedback system enabled

πŸš€ Deployment

Production Setup

  1. Environment Configuration

    # Set production environment
    export DEBUG=False
    export ALLOWED_HOSTS=['yourdomain.com']
    export SECRET_KEY='your-secure-secret-key'
  2. Database Setup

    # Apply all migrations
    python manage.py migrate
    
    # Collect static files
    python manage.py collectstatic --noinput
  3. Server Configuration

    # Using Gunicorn (recommended)
    pip install gunicorn
    gunicorn core.wsgi:application --bind 0.0.0.0:8000
    
    # Using Docker
    docker build -t polls-app .
    docker run -p 8000:8000 polls-app

Performance Considerations

  • Static Files: Use CDN or cloud storage in production
  • Database: PostgreSQL/MySQL for high-traffic applications
  • Caching: Implement Redis or Memcached for performance
  • Load Balancing: Nginx + multiple Gunicorn instances

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style Guidelines

  • Python: Follow PEP 8 and Django conventions
  • CSS: Use BEM methodology, maintain responsive design
  • JavaScript: ES6+ features, modular structure
  • Templates: Follow Django template best practices
  • File Headers: Include script name, description, and author

Commit Message Format

<type>(<scope>): <subject>

<body>

<footer>

Types: feat, fix, docs, style, refactor, test, chore

Issue Reporting

  • Bug Reports: Use GitHub Issues with detailed steps
  • Feature Requests: Include use cases and acceptance criteria
  • Security Issues: Report privately to maintainers

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Django team for the excellent framework
  • Google Fonts for the Inter typeface
  • Background image contributor (check polls/static/polls/images/)
  • Open source community for inspiration and tools

πŸ“ž Support

For questions, support, or contributions:


Built with ❀️ using Django and modern web technologies

About

A modern, responsive polling application built with Django.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published