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:
id (AutoField) – Primary key: ID
question (CharField) – Question
num (IntegerField) – Num
type (CharField) – Type
max_choices (IntegerField) – Max choices
Relationship fields:
- Parameters:
poll (
ForeignKey
toPoll
) – Poll (related name:question
)
Reverse relationships:
- Parameters:
choice (Reverse
ForeignKey
fromChoice
) – All choices of this question (related name ofquestion
)answer (Reverse
ForeignKey
fromAnswer
) – All answers of this question (related name ofquestion
)answervote (Reverse
ForeignKey
fromAnswerVote
) – All answer votes of this question (related name ofquestion
)
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
fromAnswer
answervote_set
Type: Reverse
ForeignKey
fromAnswerVote
choice_set
Type: Reverse
ForeignKey
fromChoice
id
Type:
AutoField
Type:
IntegerField
Type:
IntegerField
objects
Type:
ForeignKey
toPoll
poll_id
Internal field, use
poll
instead.Type:
CharField
random_choice_set
Type:
CharField