A Django Polls application built by following Django's own official Polls tutorial from the ground up. The tutorial is maintained by the Django developers themselves, and this build is structured as a set of reusable apps rather than a single monolithic project.
- Poll models (
QuestionandChoice) and the database schema behind them - A registered, customized Django admin interface for managing polls
- Views and namespaced URLconfs for the index, detail, and results pages
- Templates for browsing and voting on polls
- A voting form with validation
- An automated test suite covering models and views
- Static files wired up for local development
- The Django Debug Toolbar for inspecting requests in the browser
- Code quality enforced with flake8, Black, and djLint, run automatically through pre-commit hooks
Clone the repository and cd into it:
git clone https://github.com/interglobalmedia/django-polls-app.git
cd django-polls-appCreate and activate a virtual environment:
python3 -m venv venv
source venv/bin/activateInstall the dependencies:
pip install -r requirements.txtApply migrations and create a superuser so you can access the admin interface:
python manage.py migrate
python manage.py createsuperuserRun the development server:
python manage.py runserverVisit http://127.0.0.1:8000/polls/ for the app itself, or
http://127.0.0.1:8000/admin/ to manage polls through the admin interface.
To run the test suite:
python manage.py testThis project uses flake8, Black, and djLint to keep Python and template code consistent, wired up through pre-commit hooks. After installing dependencies, set up the hooks with:
pre-commit installFor the full walkthrough behind this project, see the companion series, Creating the official Django Polls app, which breaks the build down into eight parts from initial setup through testing, static files, and next steps.