Question¶
Qualified name: intranet.apps.polls.models.Question
- class intranet.apps.polls.models.Question(*args, **kwargs)[source]¶
Bases:
ModelA 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 (
ForeignKeytoPoll) – Poll (related name:question)
Reverse relationships:
- Parameters:
choice (Reverse
ForeignKeyfromChoice) – All choices of this question (related name ofquestion)answer (Reverse
ForeignKeyfromAnswer) – All answers of this question (related name ofquestion)answervote (Reverse
ForeignKeyfromAnswerVote) – All answer votes of this question (related name ofquestion)
Methods
get_question_typesget_total_votesget_type_displayShows the label of the
type.get_users_votedis_choiceis_many_choiceis_rank_choiceis_single_choiceis_writingtrunc_questionAttributes
APPELECTIONFREE_RESPRANKSHORT_RESPSPLIT_APPSTDSTD_OTHERTYPEanswer_setType: Reverse
ForeignKeyfromAnsweranswervote_setType: Reverse
ForeignKeyfromAnswerVotechoice_setType: Reverse
ForeignKeyfromChoiceidType:
AutoFieldType:
IntegerFieldType:
IntegerFieldobjectsType:
ForeignKeytoPollpoll_idInternal field, use
pollinstead.Type:
CharFieldrandom_choice_setType:
CharField