Nobody has started this yet — be first.
Business impact
A poll exists to let people choose between at least two things. Right now POST /api/polls/ will happily create a poll with a single option -- there is nothing to vote between, so every vote on it is a foregone conclusion, and the "results" page will show 100% for the only choice no matter who votes. Beyond looking broken, this is exactly the kind of input a malformed client (a typo'd form, a partially-filled draft submitted early) can trigger by accident, silently creating junk polls that clutter every listing and confuse anyone who opens one expecting a real choice.
Problem
PollCreateSerializer.options is a ListField meant to enforce "at least two options," but its min_length currently allows a single option through.
Current behavior
POST /api/polls/ with a single-element options list returns 201 and creates the poll, instead of being rejected with 400.
Expected behavior
POST /api/polls/ with fewer than two options is rejected with 400 and a validation error under the options field -- no Poll or Option rows are created.
Steps to reproduce
cd django/poll_app source .venv/bin/activate python manage.py runserver &
curl -s -X POST http://127.0.0.1:8000/api/auth/register/ -H "Content-Type: application/json"
-d '{"username":"dave","email":"dave@example.com","password":"d-strong-password-1"}'
curl -s -X POST http://127.0.0.1:8000/api/polls/ -H "Authorization: Token $TOKEN_DAVE" -H "Content-Type: application/json" -d '{"question":"Only one choice?","options":["solo"]}'
Why this matters
This is a one-value boundary condition on a ListField's min_length, and it's already covered by a pre-existing test in polls/tests/test_api.py (test_create_poll_requires_at_least_two_options), which currently fails because of it.
Suggested approach
Look at PollCreateSerializer.options in polls/serializers.py and what "at least two" means as a min_length value on a ListField.
Acceptance criteria
Verification
.venv/bin/python manage.py test practicetickets.test_ticket02_single_option_poll_allowed -v 2 && .venv/bin/python manage.py test polls.tests.test_api.PollAPITests.test_create_poll_requires_at_least_two_options -v 2
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
$git checkout -b fix/single-option-poll-allowedFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/single-option-poll-allowedSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign inhttp://127.0.0.1:8000/api/http://127.0.0.1:8000/admin/.env.example.envSECRET_KEYDEBUGDB_*CELERY_BROKER_URLmanage.py testOr via Docker (Postgres, Redis, Django with hot reload, and a Celery worker, all wired together, migrations run automatically on startup):
docker compose up --build
Work the tickets in practicetickets/ (ticket01 through ticket07); each names one dedicated Django test module:
./practicetickets/run_tickets.sh # all 7, clean pass/fail summary
./practicetickets/run_tickets.sh -v # summary + each test's full output
.venv/bin/python manage.py test practicetickets.test_ticket01_permission_check_inverted -v 2 # a single ticket
Three of the seven tickets (01, 02, 03) also collaterally break pre-existing tests in polls/tests/; run .venv/bin/python manage.py test polls -v 2 to confirm the main suite is back to fully green once those are fixed. No Redis or Celery worker is required for any of this -- settings.py forces CELERY_TASK_ALWAYS_EAGER = True whenever "test" appears in sys.argv.
Level 1
Fix a bug
Read existing behaviour, correct it.