title: Using Django FormPreview the right way
body: <h1>My Goal</h1>
  
  <p>I have a django project with a form, and I want to display a preview page before the user submits.  </p>
  
  <h1>The problem</h1>
  
  <p>I can display a preview page using a Django <a href="https://docs.djangoproject.com/en/1.7/ref/contrib/formtools/form-preview/" rel="nofollow noreferrer">FormPreview</a>, but not all form data is displayed properly. Specifically, if I have a field with <code>choices</code>, the string values of these choices aren't displayed.  I'm also having problems applying template filters to date fields.  The end result is that some data on the preview page is visible but other data is blank:</p>
  
  <p><img src="https://i.stack.imgur.com/LJBrH.png" alt="Preview page"></p>
  
  <p>However, if I display the same data for posts that have actually been submitted, then everything displays properly:</p>
  
  <p><img src="https://i.stack.imgur.com/q2YQR.png" alt="Submitted page"></p>
  
  <h1>My Code</h1>
  
  <p><strong>models.py</strong>:</p>
  
  <pre><code>class Game(models.Model):
  
    # Game Choices
    FOOTBALL = 0
    BASKETBALL = 1
    TENNIS = 2
    OTHER = 3
    GAME_CHOICES = (
        (FOOTBALL, 'Football'),
        (BASKETBALL, 'Basketball'),
        (TENNIS, 'Tennis'),
        (OTHER, 'Other')
      )
  
    game_id = models.AutoField(primary_key=True)
    location = models.CharField(max_length=200, verbose_name="Location")
    game = models.IntegerField(choices=GAME_CHOICES, default=FOOTBALL)
    game_date = models.DateField(verbose_name='Game Date')
  </code></pre>
  
  <p><strong>forms.py</strong></p>
  
  <pre><code>class GameForm(ModelForm):
    class Meta:
      model = Game
      fields = (
        'location',
        'game',
        'game_date'
      )
  </code></pre>
  
  <p>I'm pretty sure that the problem is in my views.py: I'm not sure that I'm processing the <code>POST</code> request the right way to feed all data to the preview page.</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def form_upload(request):
    if request.method == 'GET':
      form = GameForm()
    else:
      # A POST request: Handle Form Upload
      form = GameForm(request.POST) # Bind data from request.POST into a GameForm
      # If data is valid, proceeds to create a new game and redirect the user
      if form.is_valid():
        game = form.save()
        return render(request, 'games/success.html', {})
    return render(request, 'games/form_upload.html', {
      'form': form,
    })
  </code></pre>
  
  <p><strong>preview.py</strong></p>
  
  <pre><code>class GameFormPreview(FormPreview):
  
    form_template = 'games/form_upload.html'
    preview_template = 'games/preview.html'
  
    def done(self, request, cleaned_data):
      # Do something with the cleaned_data, then redirect
      # to a "success" page.
      return HttpResponseRedirect('/games/success')
  </code></pre>
  
  <p><strong>form_upload.html</strong></p>
  
  <pre><code>...
  &lt;form method="post"&gt;
    {% csrf_token %}
    &lt;ul&gt;&lt;li&gt;{{ form.as_p }}&lt;/li&gt;&lt;/ul&gt;
  
    &lt;button type="submit"&gt;Preview your post&lt;/button&gt;
  &lt;/form&gt;
  ...
  </code></pre>
  
  <p><strong>preview.html</strong></p>
  
  <pre><code>{% load humanize %}
  ...
  &lt;h1&gt;Preview your submission&lt;/h1&gt;
  
    &lt;div&gt;
      &lt;p&gt;Location: {{ form.data.location }}&lt;/p&gt;
      &lt;p&gt;Game Date: {{ form.data.game_date|date:"l, F d, Y" }}&lt;/p&gt;
      &lt;p&gt;Game Type: {{ form.data.get_game_display }}&lt;/p&gt;
    &lt;/div&gt;
  
    &lt;div&gt;
      &lt;form action="{% url 'form_upload' %}" method="post"&gt;
        {% csrf_token %}
        {% for field in form %}
        {{ field.as_hidden }}
        {% endfor %}
        &lt;input type="hidden" name="{{ stage_field }}" value="2" /&gt;
        &lt;input type="hidden" name="{{ hash_field }}" value="{{ hash_value }}" /&gt;
  
        &lt;!-- Submit button --&gt;
        &lt;button type="submit"&gt;Submit your post&lt;/button&gt;
        &lt;!-- Go back button --&gt;
        &lt;button type="submit"&gt;
          &lt;a href="{% url 'form_upload' %}" 
            onClick="history.go(-1);return false;" &gt;
            Go back and edit your post
          &lt;/a&gt;
        &lt;/button&gt;
  
        &lt;/div&gt;
  
      &lt;/form&gt;
    &lt;/div&gt;
  ...
  </code></pre>
  
  <h1>Two issues</h1>
  
  <p>Essentially, I'm having these two issues:</p>
  
  <ol>
  <li>String values for <code>choices</code> are not displayed. If I use the <a href="https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_FOO_display" rel="nofollow noreferrer">get_FOO_display()</a> method in my <code>preview.html</code> template, it returns blank. However, if I use this in a page after the post has been submitted, it displays properly.</li>
  <li>The <code>humanize</code> date filter doesn't work.  If I apply a <code>humanize</code> filter (<code>{{ form.data.game_date|date:"l, F d, Y" }}</code>) in <code>preview.html</code>, it also displays blank.  Again, this works for submitted posts.</li>
  </ol>
  
  <p>My question essentially is: what's the right way to use the <code>FormPreview</code> here?</p>