title: How can I show a loading animation in Django while the server is processing a view?
body: <p>So I'm currently working on a Django project that has a view that takes quite a bit of time to load and it can be rather user unfriendly to keep the user wondering what's wrong with the website until the page loads.</p>
  
  <p>My website works in way such that the user would have a url such as: </p>
  
  <pre><code>http://www.example.com/Name/JohnRichards
  </code></pre>
  
  <p>Saved to their bookmarks. Upon visiting the above URL the server should display a loading message (probably with a GIF and AJAX or JS) of a loading screen until the server finishes loading data and then display it.</p>
  
  <p><strong>Note:</strong> Just in case it matters, when he user goes to the above mentioned link, they won't be redirected there, rather, this would be their entry point since it's a url that they have saved in their bookmarks</p>
  
  <p>What I thought would work is returning some sort of a loading template of sorts as soon as somebody visits the page, and then after the data processing has finished, I would return the final response. But I can't have two returns in a function.</p>
  
  <p>The following is my urls.py file:</p>
  
  <pre><code>from django.contrib import admin
  from django.urls import path
  from myapp import views
  
  urlpatterns = [
      path('', views.index, name='index'),
      path('Name/'+'&lt;str:Name&gt;', views.NameInLink, name='NameInLink'),
  ]
  </code></pre>
  
  <p>And the following is my views.py file</p>
  
  <pre><code>from django.shortcuts import render
  from django.http import HttpResponse
  from django.http import HttpResponseRedirect
  from .forms import NameForm
  from . import DataProcessor
  import time
  
  def NameInLink(request, Name):
      UserData = DataProcessor.process(Name)
      return render(request, "UserData.html", {"UserData": UserData})
  </code></pre>
  
  <p>How could I add a loading screen of sorts between user using visiting the URL and the data processing finishing? </p>