Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- poll_qs = Poll.objects.filter(
- event=event
- ).prefetch_related(
- 'polloption_set',
- Prefetch(
- 'pollanswer_set',
- queryset=PollAnswer.objects.filter(singer=singer_choir_profile).select_related('option').first(),
- to_attr='answer'
- )
- )
- for poll in poll_qs:
- if poll.answer:
- poll_answer_form = PollAnswerForm(
- poll,
- singer_choir_profile,
- poll.polloption_set.all(),
- data or None,
- initial={'option_%s' % poll.id: poll.answer[0].option.id}
- )
- else:
- poll_answer_form = PollAnswerForm(
- poll,
- singer_choir_profile,
- poll.polloption_set.all(),
- data or None
- )
- poll_forms.append(poll_answer_form)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement