title: show loading gif during long processing in django?
body: <p>I do my project using Django 1.8 . I want put a GIF to during call <code>key_generate</code> function. How can I do this using Django. I  refer this question to <a href="https://stackoverflow.com/questions/8317219/django-show-loading-message-during-long-processing">reference Link</a> but I couldn't understand how apply it my code. 
  This is my view function.</p>
  
  <pre><code>from django.contrib.auth.decorators import login_required
  from django.contrib.auth.models import User
  from django.shortcuts import get_object_or_404, redirect, render
  from django.core.exceptions import PermissionDenied
  from django.http import HttpResponse
  from django.utils.timezone import now
  
  from django.shortcuts import render_to_response
  
  from .forms import BookmarkForm
  from .models import Bookmark
  
  from .forms import KeyGenarateForm
  from .models import Key_Gen
  from .algo import  algo
  
  from pymongo import MongoClient
  from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
  
  
  @login_required
  def key_create(request):
      #print(request.POST)
  
      if request.method == 'POST':
          form = KeyGenarateForm(data=request.POST)
  
  
          expier_date = request.POST['expier_date']
  
          if form.is_valid():
               #request.POST._mutable = True
               Key_Gen = form.save(commit=False)
               Key_Gen.save(expier_date)
               return redirect('marcador_bookmark_user',username=request.user.username)
          else:
              print('form not valied')
      else:
          form = KeyGenarateForm()
  
  
      context = {'form': form, 'create_key': True}
      return render(request, 'marcador/key_genarate_form.html', context)
  </code></pre>
  
  <p>This is my form  class.</p>
  
  <pre><code>{% extends "base.html" %}
  {% load crispy_forms_tags %}
  
  {% block title %}
    {% if create %}Create{% else %}New Key{% endif %}Serious
  {% endblock %}
  
  {% block heading %}
    &lt;h2&gt;
        Create New Serial Keys
    &lt;/h2&gt;
  {% endblock %}
  
  {% block content %}
    {% if create %}
      {% url "marcador_key_create" as action_url %}
    {% else %}
      {% url "marcador_bookmark_search" pk=form.instance.pk as action_url %}
    {% endif %}
    &lt;form action="{{ action_url }}" method="post" accept-charset="utf-8" &gt;
      {{ form|crispy }}
      {% csrf_token %}
      &lt;p&gt; &lt;b&gt;Expiry Date*:&lt;/b&gt;  &lt;input type="date" id="datepicker" name="expier_date"&gt;&lt;/p&gt;
      &lt;p&gt;&lt;input type="submit" class="btn btn-default" value="Save" &gt;&lt;/p&gt;
    &lt;/form&gt;
  {% endblock %}
  </code></pre>
  
  <h2>Further explanation:</h2>
  
  <p>I generate 10000 serial keys using this forum.
  <a href="https://i.stack.imgur.com/xfcCg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xfcCg.png" alt="enter image description here"></a></p>
  
  <p>This keys store in mongoDB database. System spend 3 -4 minutes to this task.I want show some thing [ Example : loading image or wait message ]  during this time period. </p>