title: Django redirect on error to main home page or app root
body: <p>I'm trying to not hardcode the url of the app in the view (really the controller) of an app. </p>
  
  <p>Code looks like this: </p>
  
  <pre><code>event/view.py
  
  def index(request):
  
    try:
      //do stuff with response
      return render(request, 'rma/service.html', response)
    except:
      return redirect("/rma")
  </code></pre>
  
  <p>In this case the app is installed on the web server under /var/www/html/rma. but in production (or anywhere else) it could be installed at any subdirectory or html/ </p>
  
  <p>How can I redirect to the main page because if this specific page fails the main page will display better logic of what's going on (sources missing in DB, table not imported, etc.) </p>
  
  <p>i'd like to do something like:</p>
  
  <pre><code>return redirect(&lt;magic&gt;.main.index) 
  </code></pre>
  
  <p>or even like:</p>
  
  <pre><code>return redirect(APP_ROOT)
  </code></pre>
  
  <p>All example i found is redirecting inside html (the template) rather than in code in the view.py</p>
  
  <p>Any ideas? </p>