Question

Qualified name: intranet.apps.polls.models.Question

class intranet.apps.polls.models.Question(*args, **kwargs)[source]

Bases: Model

A question for a Poll.

poll

A ForeignKey to the Poll object the question is for.

question

A text field for entering the question, of which there are choices the user can make.

num

An integer order in which the question should appear; the primary sort.

type
One of:

Question.STD: Standard Question.ELECTION: Election (randomized choice order) Question.RANK: Rank choice election Question.APP: Approval (can select up to max_choices entries) Question.SPLIT_APP: Split approval Question.FREE_RESP: Free response Question.STD_OTHER: Standard Other field

max_choices

The maximum number of choices that can be selected. Only applies for approval questions.

Access possible choices for this question through question.choice_set.all()
Parameters:

Relationship fields:

Parameters:

poll (ForeignKey to Poll) – Poll (related name: question)

Reverse relationships:

Parameters:
  • choice (Reverse ForeignKey from Choice) – All choices of this question (related name of question)

  • answer (Reverse ForeignKey from Answer) – All answers of this question (related name of question)

  • answervote (Reverse ForeignKey from AnswerVote) – All answer votes of this question (related name of question)

Methods

get_question_types

get_total_votes

get_type_display

Shows the label of the type.

get_users_voted

is_choice

is_many_choice

is_rank_choice

is_single_choice

is_writing

trunc_question

Attributes

APP

ELECTION

FREE_RESP

RANK

SHORT_RESP

SPLIT_APP

STD

STD_OTHER

TYPE

answer_set

Type: Reverse ForeignKey from Answer

answervote_set

Type: Reverse ForeignKey from AnswerVote

choice_set

Type: Reverse ForeignKey from Choice

id

Type: AutoField

max_choices

Type: IntegerField

num

Type: IntegerField

objects

poll

Type: ForeignKey to Poll

poll_id

Internal field, use poll instead.

question

Type: CharField

random_choice_set

type

Type: CharField