title: How to retrieve selected data from Django Choice Field?
body: <p>I want to retrieve the <code>question_description</code> <code>answer_descritption</code> and <code>question_image</code> <code>answer_image</code> if found in the database according to topic and question type using two <code>ChoiceField</code> for both: Topic and Question Type.</p>
  
  <p>However, I don't know how to do that. I have seen some tutorials and gotten glimpses of what I have to do, but I am not sure how to preform the same techniques on my case because online there are not that many <code>ChoiceField</code> examples, except that there are general examples on how to use forms and extract data from the database.</p>
  
  <p>This is the <code>models.py</code></p>
  
  <pre><code>from django.db import models
  from home.choices import *
  
  # Create your models here.
  
  class Topic(models.Model):
      topic_name = models.IntegerField(
                      choices = question_topic_name_choices, default = 1)
      def __str__(self):
          return '%s' % self.topic_name
  
  class Image (models.Model):
      image_file = models.ImageField()
  
      def __str__(self):
          return '%s' % self.image_file
  
  class Question(models.Model):
      question_type = models. IntegerField(
                      choices = questions_type_choices, default = 1)
      question_topic = models.ForeignKey(    'Topic',
                                      on_delete=models.CASCADE,
                                      blank=True,
                                      null=True)
      question_description = models.TextField()
      question_answer = models.ForeignKey(    'Answer',
                                      on_delete=models.CASCADE,
                                      blank=True,
                                      null=True)
      question_image = models.ForeignKey(    'Image',
                                      on_delete=models.CASCADE,
                                      blank=True,
                                      null=True)
  
      def __str__(self):
          return '%s' % self.question_type
  
  class Answer(models.Model):
      answer_description = models.TextField()
      answer_image = models.ForeignKey(    'Image',
                                      on_delete=models.CASCADE,
                                      blank=True,
                                      null=True)
      answer_topic = models.ForeignKey(    'Topic',
                                      on_delete=models.CASCADE,
                                      blank=True,
                                      null=True)
      def __str__(self):
          return '%s' % self.answer_description
  </code></pre>
  
  <p>This is the <code>forms.py</code></p>
  
  <pre><code>from django import forms
  from betterforms.multiform import MultiModelForm
  from .models import Topic, Image, Question, Answer
  from .choices import questions_type_choices, question_topic_name_choices
  
  class TopicForm(forms.ModelForm):
      topic_name      =   forms.ChoiceField(
                      choices=question_topic_name_choices,
                      widget = forms.Select(
                      attrs = {'class': 'home-select-one'}
                          ))
  
      class Meta:
          model = Topic
          fields = ['topic_name',]
          def __str__(self):
              return self.fields
  
  
  class QuestionForm(forms.ModelForm):
      question_type =   forms.ChoiceField(
                      choices= questions_type_choices,
                      widget = forms.Select(
                      attrs = {'class': 'home-select-two'},
                          ))
  
      class Meta:
          model = Question
          fields = ['question_type',]
          def __str__(self):
              return self.fields
  
  
  class QuizMultiForm(MultiModelForm):
      form_classes    =   {
                  'topics':TopicForm,
                  'questions':QuestionForm
      }
  </code></pre>
  
  <p>This is the <code>views.py</code></p>
  
  <pre><code>from django.shortcuts import render, render_to_response
  from django.views.generic import TemplateView
  from home.models import Topic, Image, Question, Answer
  from home.forms import QuizMultiForm
  
  
  
  
  class QuizView(TemplateView):
      template_name = 'index.html'
      def get(self, request):
    # What queries do I need to put here to get the question and answer's description according to the ChoiceField input
          form = QuizMultiForm()
          return render (request, self.template_name, {'form': form})
  
      def post(self, request):
          form = QuizMultiForm(request.POST)
          if form.is_valid():
              text = form.cleaned_data['topic_name', 'question_type'] # I don't know what to put here!
  
          args = {'form': form, 'text': text}
          return render (request, self.template_name, args)
  </code></pre>
  
  <p>This is the template:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    {% extends 'base.html' %}
        {% block content %}
              &lt;form  method="POST"&gt;
                {% csrf_token %}
                {{ form.as_p }}
                &lt;button type="submit" id="home-Physics-time-button"&gt;It is Physics Time&lt;/button&gt;
                &lt;h1&gt; {{ text }} &lt;/h1&gt;
              &lt;/form&gt;
          {% endblock content %}</code></pre>
  </div>
  </div>
  </p>
  
  <p>I would appropriate the help!
  Thank you!</p>